Suppose I would like to generate random numbers in a way that they satisfy some probability distribution with a mean $\mu$ and standard deviation $\sigma$, what is a formula for that?
Thank you.
Suppose I would like to generate random numbers in a way that they satisfy some probability distribution with a mean $\mu$ and standard deviation $\sigma$, what is a formula for that?
Thank you.
The following strategy is very general. Let $F(x)$ be the cumulative distribution of $X$. Assume $F$ is invertible and $U$ is a uniform random variable in $(0,1)$. Then $F^{-1}(U)$ is distributed as $X$. The proof is very simple:
$P(F^{-1}(U) \leq x) = P(F(F^{-1}(U)) \leq F(x)) = P(U \leq F(x)) = F(x)$
For example, if $X$ follows an exponential distribution with parameter $\lambda$,
$F(x) = 1-e^{-\lambda x}$
$x = -\frac{\log(1-F(x))}{\lambda}$
Hence, $-\frac{\log(1-U)}{\lambda}$ follows an exponential distribution with parameter $\lambda$.
As far as I know, there is no way to generate "true" uniform random numbers using a formula. All formulas are deterministic. Most cryptographically-secure methods of generating random numbers require the use of specialized hardware. There are circuits to perform random number generation. Once you have a uniform distribution of numbers you can then use something such as the Box-Muller transform to get normally distributed random numbers. Or maybe the Ziggurat algorithm is what you are looking for?
Perhaps use an algorithm that can generate random numbers with mean $\mu$ and standard deviation $\sigma$ for any type of distribution. The algorithm is not completely "random", and it is not a formula, but it is a process that can give fairly good random numbers.
For a ready-made solution, Matlab normrnd might be what you are looking for, if you want normally distributed random numbers.
If you want to generate sample numbers at random from any probability distribution, then the inverse transform sampling method might be the way to go.
In short, generate uniform random numbers, and then use other methods (Random number generation) to get the random numbers from the distribution that you want.