Using binornd function - problem with draw variability
Show older comments
Hi, I have a problem with the binornd function in simulink. I use it:
v=binornd(1,p)

'p' is variable from 0 to 1, forming on a curve (the same curve in each simulation) (the attached screen - probability; the 1st graph).
Below (2nd graph in attached screen) it is the result of the draw, with time step 0.01 sec. It is the same result for each time.
I wish that this distribution will be varies in accordance with the pseudo-random nature of the function binornd.
Do you know how to set this function, that for every time changed the results of the draw?
(It seems as grain was always the same - in r programm I can change it, but in matlab i don't know)
Regards, Sz.
Answers (1)
Roger Stafford
on 16 May 2016
By writing “binornd(1,p)” you are restricting yourself to the values 0 and 1 with probabilities 1-p and p. To get a larger range use “binornd(n,p)” which will have a range of 0 to n. See:
http://www.mathworks.com/help/stats/binornd.html
2 Comments
Szymon Wer
on 17 May 2016
Edited: Szymon Wer
on 17 May 2016
Roger Stafford
on 17 May 2016
It sounds to me as if you are resetting the seed each time to the same value. That is exactly what you DON’T want to do. Either use something like rng('shuffle') or leave it alone. Read the description at:
http://www.mathworks.com/help/matlab/ref/rng.html
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!