Using binornd function - problem with draw variability
이전 댓글 표시
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.
답변 (1개)
Roger Stafford
2016년 5월 16일
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
Szymon Wer
2016년 5월 17일
편집: Szymon Wer
2016년 5월 17일
Roger Stafford
2016년 5월 17일
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
카테고리
도움말 센터 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!