mercredi 29 avril 2015

Random python selection within a ranged distribution

I have a normal distributed range from 10 to 100 with an average of 25. I am wanting to randomly sample this. Using:

random.gauss(25, 5)

I can obtain get a sample where the mean is 25 and the standard deviation is 6. Meaning only a 1% chance of getting outside of my lower limit. Obviously though this is not putting a high enough waiting on my upper limit and I will at most reach 40.

At present the only way I can think to hit the upper limit is to look at both the upper and lower with using a decision rule to look at the upper half 50% using

random.gauss(25, 25) 

of the time and lower the other 50% and have the first snippet. Only consider values higher than the mean for the upper and lesser than the mean for the other.

Is there any other way I can make this anymore precise. I have seen online ways of skewing a normal distribution but unsure how I can get that to work as my stats really isn't that strong.

Thanks in advance for any assistance.




Aucun commentaire:

Enregistrer un commentaire