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!