better random number generator needed
better random number generator needed
(OP)
hi all
matlab has two main random number generators we surely all know about: rand and randn
randn uses a 0 mean, 1 std gaussian distribution
yet i very much miss a random number generator WHERE i can SPECIFY the mean and std i want it to use (very useful when trying to compare ur data to random data that needs to have the SAME mean and variance...)
i ll keep on looking on google, but any help is welcome
regards
matlab has two main random number generators we surely all know about: rand and randn
randn uses a 0 mean, 1 std gaussian distribution
yet i very much miss a random number generator WHERE i can SPECIFY the mean and std i want it to use (very useful when trying to compare ur data to random data that needs to have the SAME mean and variance...)
i ll keep on looking on google, but any help is welcome
regards





RE: better random number generator needed
To generate a random distribution with a specific mean and variance, multiply the output of randn by the standard deviation, and then add the desired mean.
ie: x = my_mean + sqrt(my_variance) * randn(nrows,ncols)
For example, to generate a 5-by-5 array of random numbers with a mean of .6 that are distributed with a variance of 0.1 x = .6 + sqrt(0.1) * randn(5)