×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

better random number generator needed

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

RE: better random number generator needed

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources