Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

better random number generator needed 1

Status
Not open for further replies.

antiseptic

Bioengineer
Jan 15, 2003
11
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
 
Replies continue below

Recommended for you

See example 2 under help for randn.

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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor