Generating a gaussian distribution with only positive numbers

Viewed 31514

Is there any way to randomly generate a set of positive numbers such that they have a desired mean and standard deviation?

I have an algorithm to generate numbers with a gaussian distribution, but I don't know how to deal with negative numbers in a way the preserves the mean and standard deviation.
It looks like a poisson distribution might be a good approximation, but it takes only a mean.

EDIT: There's been some confusion in the responses so I'll try to clarify.

I have a set of numbers that give me a mean and a standard deviation. I would like to generate an equally sized set of numbers with an equivalent mean and standard deviation. Normally, I would use a gaussian distribution to do this, however in this case I have an additional constraint that all values must be greater than zero.

The algorithm I'm looking for doesn't need to be gaussian-based (judging by the comments so far, it probably shouldn't be) and doesn't need to be perfect. It doesn't matter if the resulting number set has a slightly different mean/standard deviation -- I just want something that will usually be in the ballpark.

7 Answers

You could use any distribution which has positive support AND can be specified by mean and variance. For example,

  • one-parameter distributions won't work in general. For example chi-square won't work unless your variance is always double its mean. Similarly exponential won't work unless your variance equals your mean squared.
  • some two-parameter distributions won't work in some cases. Binomial distribution won't work unless variance is less than your mean. Similarly the non-central chi-square won't work unless your variance is greater than 2 times your mean and less than 4 times your mean!
  • However log-normal and gamma will work in all cases.
Related