How do I generate distribution of positive numbers only with min, max and mean?Calculating distribution from...
Iterate over non-const variables in C++
Convert a string like 4h53m12s to a total number of seconds in JavaScript
What was the rationale behind 36 bit computer architectures?
How important is a good quality camera for good photography?
Is it correct to translate English noun adjuncts into adjectives?
How to write a sincerely religious protagonist without preaching or affirming or judging their worldview?
Why no ";" after "do" in sh loops?
How do I stop my characters falling in love?
Is it legal for private citizens to "impound" e-scooters?
Knights fighting a steam locomotive they believe is a dragon
Why is a dedicated QA team member necessary?
TSA asking to see cell phone
Why is chess failing to attract big name sponsors?
Do the licences permit GPL- and BSD-licensed applications to be used for government work?
How to contact Apple to check if they will permit an iOS app?
Why is my read in of data taking so long?
How can I prevent corporations from growing their own workforce?
How were the LM astronauts supported during the moon landing and ascent? What were the max G's on them during these phases?
Creating Darkness
Send a single HTML email from Thunderbird, overriding the default "plain text" setting
High income, sudden windfall
Q: What is a Checkmate Word™?
Is it legal to use cash pulled from a credit card to pay the monthly payment on that credit card?
How do I run a game when my PCs have different approaches to combat?
How do I generate distribution of positive numbers only with min, max and mean?
Calculating distribution from min, mean, and maxHow to perform goodness of fit test and how to assign probability with uniform distribution?How to generate a non-normal correlated bivariate distributionHow do I test for a symmetric distribution?Truncate lognormal distribution with excelAre there any inverse distribution graph that looks like this?Generate data with skewed distribution and known percentiles, mean and medianSimulating data from an unknown distribution given min and max valuesEstimating gamma distribution parameters using sample mean and stdHow to draw one standard deviation range around the mean of a skewed distributionSample from a distribution if only mean median max etc. are given
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
I am trying to generate a sample of 2000 rows. I have the following values
min = 80
max = 12000
mean = 500
I want to generate only positive numbers. I tried using triangular distribution and range rule(sd = max-min/4). The values were negative.
Is there anyway I can generate only positive numbers?
Thanks,
Anusha
distributions simulation
$endgroup$
add a comment |
$begingroup$
I am trying to generate a sample of 2000 rows. I have the following values
min = 80
max = 12000
mean = 500
I want to generate only positive numbers. I tried using triangular distribution and range rule(sd = max-min/4). The values were negative.
Is there anyway I can generate only positive numbers?
Thanks,
Anusha
distributions simulation
$endgroup$
1
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago
add a comment |
$begingroup$
I am trying to generate a sample of 2000 rows. I have the following values
min = 80
max = 12000
mean = 500
I want to generate only positive numbers. I tried using triangular distribution and range rule(sd = max-min/4). The values were negative.
Is there anyway I can generate only positive numbers?
Thanks,
Anusha
distributions simulation
$endgroup$
I am trying to generate a sample of 2000 rows. I have the following values
min = 80
max = 12000
mean = 500
I want to generate only positive numbers. I tried using triangular distribution and range rule(sd = max-min/4). The values were negative.
Is there anyway I can generate only positive numbers?
Thanks,
Anusha
distributions simulation
distributions simulation
asked 8 hours ago
user3437212user3437212
324 bronze badges
324 bronze badges
1
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago
add a comment |
1
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago
1
1
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
While the problem is very much ill-posed, since there is an infinite range of distributions satisfying these constraints, a possible solution is to find the maximum entropy distribution under the constraint of a support of $(80,12000)$ [thus using the uniform measure on that interval as the reference measure] and a mean of $mathbb E[X]=500$ is of the form
$$p(x)=exp{alpha+beta x},mathbb I_{(80,1200)}(x)$$
with
$$int_{80}^{12000} exp{alpha+beta x},text dx=1qquadtext{and}qquad
int_{80}^{12000} xexp{alpha+beta x},text dx=500$$
which leads to
$$exp{-alpha}=beta^{-1}[exp{12000beta}-exp{80beta}]$$
and$$beta^{-1}exp{alpha}[12000exp{12000beta}-80exp{80beta}]-beta^{-1}=500$$which can be solved numerically in $beta$. Leading to
$$beta^*=-.00238quadtext{and}quadalpha^*=-5.850$$which can be easily simulated as a truncated exponential distribution, by inversion of the cdf, e.g., using qexp() in R. For instance,
function(n=1)
return(qexp(pexp(80,.00238)+runif(n)*
(pexp(12000,.00238)-pexp(80,.00238)),.00238))
If the question is instead about simulating a sample $X_{1:2000}$ such that $$min(X_{1:2000})=80,quadmax(X_{1:2000})=1200,quadbar X_{1:2000}=500$$
there is again an infinite range of solutions, the simplest being a multinomial distribution constrained by its minimum being 80 and its maximum being 12000 since
$$underbrace{X_{(1)}}_{80}+cdots+underbrace{X_{(2000)}}_{12000} = 80 + 1998times 987920 + 12000= 2000times 500$$
$endgroup$
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
add a comment |
$begingroup$
If you don't care about the distribution aside from min, max, and mean, then there is a simple answer.
Take 96.476510067114100 percent of draws as 80 and 3.523489932885910 percent of draws as 12000. On average, you get 500, and you have your min and max. I calculated the percentages by solving a system of equations
$$a + b =1$$ $$80a + 12000b = 500$$
The first equation establishes the the values must sum to one, making sure that we are dealing with probabilities. The second equation get us our average of 500.
D <- rep(NA,2000) # define a vector of NAs to hold your sampled values
for (i in 1:2000){
X <- rbinom(1,1,0.96476510067114100) # determine which value you'll take, 80 or 12000
if (X==0){D[i] <- 12000} # declare observation i as 12000
if (X==1){D[i] <- 80} # declare observation i as 80
}
$endgroup$
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "65"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f419348%2fhow-do-i-generate-distribution-of-positive-numbers-only-with-min-max-and-mean%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
While the problem is very much ill-posed, since there is an infinite range of distributions satisfying these constraints, a possible solution is to find the maximum entropy distribution under the constraint of a support of $(80,12000)$ [thus using the uniform measure on that interval as the reference measure] and a mean of $mathbb E[X]=500$ is of the form
$$p(x)=exp{alpha+beta x},mathbb I_{(80,1200)}(x)$$
with
$$int_{80}^{12000} exp{alpha+beta x},text dx=1qquadtext{and}qquad
int_{80}^{12000} xexp{alpha+beta x},text dx=500$$
which leads to
$$exp{-alpha}=beta^{-1}[exp{12000beta}-exp{80beta}]$$
and$$beta^{-1}exp{alpha}[12000exp{12000beta}-80exp{80beta}]-beta^{-1}=500$$which can be solved numerically in $beta$. Leading to
$$beta^*=-.00238quadtext{and}quadalpha^*=-5.850$$which can be easily simulated as a truncated exponential distribution, by inversion of the cdf, e.g., using qexp() in R. For instance,
function(n=1)
return(qexp(pexp(80,.00238)+runif(n)*
(pexp(12000,.00238)-pexp(80,.00238)),.00238))
If the question is instead about simulating a sample $X_{1:2000}$ such that $$min(X_{1:2000})=80,quadmax(X_{1:2000})=1200,quadbar X_{1:2000}=500$$
there is again an infinite range of solutions, the simplest being a multinomial distribution constrained by its minimum being 80 and its maximum being 12000 since
$$underbrace{X_{(1)}}_{80}+cdots+underbrace{X_{(2000)}}_{12000} = 80 + 1998times 987920 + 12000= 2000times 500$$
$endgroup$
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
add a comment |
$begingroup$
While the problem is very much ill-posed, since there is an infinite range of distributions satisfying these constraints, a possible solution is to find the maximum entropy distribution under the constraint of a support of $(80,12000)$ [thus using the uniform measure on that interval as the reference measure] and a mean of $mathbb E[X]=500$ is of the form
$$p(x)=exp{alpha+beta x},mathbb I_{(80,1200)}(x)$$
with
$$int_{80}^{12000} exp{alpha+beta x},text dx=1qquadtext{and}qquad
int_{80}^{12000} xexp{alpha+beta x},text dx=500$$
which leads to
$$exp{-alpha}=beta^{-1}[exp{12000beta}-exp{80beta}]$$
and$$beta^{-1}exp{alpha}[12000exp{12000beta}-80exp{80beta}]-beta^{-1}=500$$which can be solved numerically in $beta$. Leading to
$$beta^*=-.00238quadtext{and}quadalpha^*=-5.850$$which can be easily simulated as a truncated exponential distribution, by inversion of the cdf, e.g., using qexp() in R. For instance,
function(n=1)
return(qexp(pexp(80,.00238)+runif(n)*
(pexp(12000,.00238)-pexp(80,.00238)),.00238))
If the question is instead about simulating a sample $X_{1:2000}$ such that $$min(X_{1:2000})=80,quadmax(X_{1:2000})=1200,quadbar X_{1:2000}=500$$
there is again an infinite range of solutions, the simplest being a multinomial distribution constrained by its minimum being 80 and its maximum being 12000 since
$$underbrace{X_{(1)}}_{80}+cdots+underbrace{X_{(2000)}}_{12000} = 80 + 1998times 987920 + 12000= 2000times 500$$
$endgroup$
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
add a comment |
$begingroup$
While the problem is very much ill-posed, since there is an infinite range of distributions satisfying these constraints, a possible solution is to find the maximum entropy distribution under the constraint of a support of $(80,12000)$ [thus using the uniform measure on that interval as the reference measure] and a mean of $mathbb E[X]=500$ is of the form
$$p(x)=exp{alpha+beta x},mathbb I_{(80,1200)}(x)$$
with
$$int_{80}^{12000} exp{alpha+beta x},text dx=1qquadtext{and}qquad
int_{80}^{12000} xexp{alpha+beta x},text dx=500$$
which leads to
$$exp{-alpha}=beta^{-1}[exp{12000beta}-exp{80beta}]$$
and$$beta^{-1}exp{alpha}[12000exp{12000beta}-80exp{80beta}]-beta^{-1}=500$$which can be solved numerically in $beta$. Leading to
$$beta^*=-.00238quadtext{and}quadalpha^*=-5.850$$which can be easily simulated as a truncated exponential distribution, by inversion of the cdf, e.g., using qexp() in R. For instance,
function(n=1)
return(qexp(pexp(80,.00238)+runif(n)*
(pexp(12000,.00238)-pexp(80,.00238)),.00238))
If the question is instead about simulating a sample $X_{1:2000}$ such that $$min(X_{1:2000})=80,quadmax(X_{1:2000})=1200,quadbar X_{1:2000}=500$$
there is again an infinite range of solutions, the simplest being a multinomial distribution constrained by its minimum being 80 and its maximum being 12000 since
$$underbrace{X_{(1)}}_{80}+cdots+underbrace{X_{(2000)}}_{12000} = 80 + 1998times 987920 + 12000= 2000times 500$$
$endgroup$
While the problem is very much ill-posed, since there is an infinite range of distributions satisfying these constraints, a possible solution is to find the maximum entropy distribution under the constraint of a support of $(80,12000)$ [thus using the uniform measure on that interval as the reference measure] and a mean of $mathbb E[X]=500$ is of the form
$$p(x)=exp{alpha+beta x},mathbb I_{(80,1200)}(x)$$
with
$$int_{80}^{12000} exp{alpha+beta x},text dx=1qquadtext{and}qquad
int_{80}^{12000} xexp{alpha+beta x},text dx=500$$
which leads to
$$exp{-alpha}=beta^{-1}[exp{12000beta}-exp{80beta}]$$
and$$beta^{-1}exp{alpha}[12000exp{12000beta}-80exp{80beta}]-beta^{-1}=500$$which can be solved numerically in $beta$. Leading to
$$beta^*=-.00238quadtext{and}quadalpha^*=-5.850$$which can be easily simulated as a truncated exponential distribution, by inversion of the cdf, e.g., using qexp() in R. For instance,
function(n=1)
return(qexp(pexp(80,.00238)+runif(n)*
(pexp(12000,.00238)-pexp(80,.00238)),.00238))
If the question is instead about simulating a sample $X_{1:2000}$ such that $$min(X_{1:2000})=80,quadmax(X_{1:2000})=1200,quadbar X_{1:2000}=500$$
there is again an infinite range of solutions, the simplest being a multinomial distribution constrained by its minimum being 80 and its maximum being 12000 since
$$underbrace{X_{(1)}}_{80}+cdots+underbrace{X_{(2000)}}_{12000} = 80 + 1998times 987920 + 12000= 2000times 500$$
edited 6 hours ago
answered 7 hours ago
Xi'anXi'an
61.7k8 gold badges99 silver badges376 bronze badges
61.7k8 gold badges99 silver badges376 bronze badges
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
add a comment |
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
Is your comment about $X_{1:2000}$ about ensuring that the sample (not the population) has a mean of 500? Also, two clarifications would be helpful. 1) Why do something in the form of $exp{alpha + beta X}$? 2) Once we solve for $alpha$ and $beta$, how do to simulate draws from that PDF?
$endgroup$
– Dave
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
As indicated in the answer, the second interpretation of the question is to see all the constraints as constraints on the sample, not on the distribution. And as indicated in the answer, the (truncated) exponential form of the distribution follows from maximum entropy principles.
$endgroup$
– Xi'an
7 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
$begingroup$
@Xi'an Thank you this helps!
$endgroup$
– user3437212
6 hours ago
add a comment |
$begingroup$
If you don't care about the distribution aside from min, max, and mean, then there is a simple answer.
Take 96.476510067114100 percent of draws as 80 and 3.523489932885910 percent of draws as 12000. On average, you get 500, and you have your min and max. I calculated the percentages by solving a system of equations
$$a + b =1$$ $$80a + 12000b = 500$$
The first equation establishes the the values must sum to one, making sure that we are dealing with probabilities. The second equation get us our average of 500.
D <- rep(NA,2000) # define a vector of NAs to hold your sampled values
for (i in 1:2000){
X <- rbinom(1,1,0.96476510067114100) # determine which value you'll take, 80 or 12000
if (X==0){D[i] <- 12000} # declare observation i as 12000
if (X==1){D[i] <- 80} # declare observation i as 80
}
$endgroup$
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
|
show 1 more comment
$begingroup$
If you don't care about the distribution aside from min, max, and mean, then there is a simple answer.
Take 96.476510067114100 percent of draws as 80 and 3.523489932885910 percent of draws as 12000. On average, you get 500, and you have your min and max. I calculated the percentages by solving a system of equations
$$a + b =1$$ $$80a + 12000b = 500$$
The first equation establishes the the values must sum to one, making sure that we are dealing with probabilities. The second equation get us our average of 500.
D <- rep(NA,2000) # define a vector of NAs to hold your sampled values
for (i in 1:2000){
X <- rbinom(1,1,0.96476510067114100) # determine which value you'll take, 80 or 12000
if (X==0){D[i] <- 12000} # declare observation i as 12000
if (X==1){D[i] <- 80} # declare observation i as 80
}
$endgroup$
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
|
show 1 more comment
$begingroup$
If you don't care about the distribution aside from min, max, and mean, then there is a simple answer.
Take 96.476510067114100 percent of draws as 80 and 3.523489932885910 percent of draws as 12000. On average, you get 500, and you have your min and max. I calculated the percentages by solving a system of equations
$$a + b =1$$ $$80a + 12000b = 500$$
The first equation establishes the the values must sum to one, making sure that we are dealing with probabilities. The second equation get us our average of 500.
D <- rep(NA,2000) # define a vector of NAs to hold your sampled values
for (i in 1:2000){
X <- rbinom(1,1,0.96476510067114100) # determine which value you'll take, 80 or 12000
if (X==0){D[i] <- 12000} # declare observation i as 12000
if (X==1){D[i] <- 80} # declare observation i as 80
}
$endgroup$
If you don't care about the distribution aside from min, max, and mean, then there is a simple answer.
Take 96.476510067114100 percent of draws as 80 and 3.523489932885910 percent of draws as 12000. On average, you get 500, and you have your min and max. I calculated the percentages by solving a system of equations
$$a + b =1$$ $$80a + 12000b = 500$$
The first equation establishes the the values must sum to one, making sure that we are dealing with probabilities. The second equation get us our average of 500.
D <- rep(NA,2000) # define a vector of NAs to hold your sampled values
for (i in 1:2000){
X <- rbinom(1,1,0.96476510067114100) # determine which value you'll take, 80 or 12000
if (X==0){D[i] <- 12000} # declare observation i as 12000
if (X==1){D[i] <- 80} # declare observation i as 80
}
edited 4 hours ago
answered 7 hours ago
DaveDave
70210 bronze badges
70210 bronze badges
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
|
show 1 more comment
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
Thanks Dave! But I don't want only 80s and 12000s in my distribution. I would like a range of values but all positive
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
$begingroup$
I'm sorry I was not clear earlier
$endgroup$
– user3437212
7 hours ago
2
2
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
We can construct a different distribution, but what requirements do you have?
$endgroup$
– Dave
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
$begingroup$
normal or a poisson but no negative values
$endgroup$
– user3437212
7 hours ago
5
5
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
$begingroup$
Normal is out, since it can take all real values. More helpful, though, would be to know what you're considering either of those distributions. So...why normal or Poisson?
$endgroup$
– Dave
7 hours ago
|
show 1 more comment
Thanks for contributing an answer to Cross Validated!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f419348%2fhow-do-i-generate-distribution-of-positive-numbers-only-with-min-max-and-mean%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
What kind of distribution of values do you want?
$endgroup$
– Dave
8 hours ago
$begingroup$
as long as they are positive and has mean = 500, min = 80 and max = 12000
$endgroup$
– user3437212
8 hours ago
$begingroup$
min and max is fine but the mean is way too off in triangular distribution, do you have any other suggestion?
$endgroup$
– user3437212
8 hours ago
$begingroup$
Strongly related: stats.stackexchange.com/q/236449/35989
$endgroup$
– Tim♦
7 hours ago