Random number generation with min, max and mean
23 views (last 30 days)
Nevzat Can Yerlikaya on 25 May 2022
Hello, I want to generate random numbers for probability function with using mean, maximum and minimum values. For example, I know the average probability of X is 0,4. What I want is to reate random numbers between 0 and 1 with most of them close to 0,4. Is there a function like this? Does this contradict the randomness of random numbers? Thank you for your help!
John D'Errico on 25 May 2022
Edited: John D'Errico on 25 May 2022
Sigh. I've probably seen different variations of this question asked at least many hundreds of times over the 40+ years I have been answering questions and doing consulting. The problem is, it has no answer. At least not one that you will be happy with in the form you asked it. That is, there are infinitely many distributions one might choose that have the properties you describe.
For example, a beta distribution is a nice example, or perhaps a truncated normal distribution. They could both have the general curve shape you describe for the PDF. But even in those two specific cases there are infinitely many choices one could make, ALL of which satisfy the requirements. And you have not given sufficient information to choose between anything.
For example, consider a beta distribution.
The one they describe there is defined on a support of [0,1], so it is perfect for your problem. That beta distribution has a mean of
alpha/(alpha + beta)
so as long as the two distribution parameters satisfy the relationship:
0.6*alpha = 0.4*beta
then the mean will be 0.4.
Since you seem to want a unimodal distribution, then they both need to be greater than 1 too. But that does not restrict things by a lot. There are still infinitely many distributions that will do as required. Conveniently, the stats toolbox beta distribution is also defined on a support of [0,1], so that is good. Here are a few distributions that all have the necessary properties:
Again, as long as alpha is exactly 2/3 of beta, then the mean will be 0.4. There would be no beta distribution where the mode AND the mean will be exactly 0.4, but as the parameters grow large in that ratio, the mode will approach 0.4 asymptotically.
I could surely do something similar for a truncated normal distribution or many others, or I could hack up an example with the mode and mean both at 0.4, though that would require me to think for a few seconds more, and it is still too early in the AM here for the brain cells to fully function.
Still, the fundamental problem is you have not said enough in your requirements. Pick any of the distributions I have shown, and they will all have a mean of 0.4, and the mode will not be too far from 0.4 either. They are all unimodal distributions.