Using normrnd to generate a random sequence

2 views (last 30 days)
I'm trying to use the function 'normrnd' to generate a zero-mean random sequence distributed uniformly between +/- 0.25. How do I go about doing this?

Accepted Answer

Roger Stafford
Roger Stafford on 12 Feb 2018
The best answer to your question is, “don’t use ‘normrnd’ for that purpose!” It is very much the wrong distribution for that.
You should use ‘rand’ as follows:
x = 0.5*rand(m,n)-0.25;
This will give you a statistically uniform distribution between -0.25 and +0.25, and nowhere else.
Nat on 12 Feb 2018
Thanks to both of you for your help!

Sign in to comment.

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by