Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating random numbers with known mean and variance

Tags:

random

From a paper I'm reading right know:

...
S(t+1, k) = S(t, k) + ... + C*∆
...
∆ is a standard random variable with mean 0 and variance 1.
...

How to generate this series of random values with this mean and variance? If someone has links to a C or C++ library I would be glad but I wouldn't mind implementing it myself if someone tells me how to do it :)

like image 245
Vitor Py Avatar asked Dec 28 '22 05:12

Vitor Py


2 Answers

Do you have any restrictions on the distribution of \Delta ? if not you can just use a uniform distribution in [-sqrt(3), sqrt(3)]. The reason why this would work is because for an uniform distribution [a,b] the variance is 1/(12) (b-a)^2.

like image 140
srean Avatar answered Feb 20 '23 02:02

srean


You can use the Box-Muller transform.

Suppose U1 and U2 are independent random variables that are uniformly distributed in the interval (0, 1]. Let

and

Then Z0 and Z1 are independent random variables with a normal distribution of standard deviation 1.

like image 44
Mark Byers Avatar answered Feb 20 '23 03:02

Mark Byers