How to generate a discrete random variable taking values from {0,1,2,3} having unifom distribution using rand. Generate a vector of 1000 such samples.
8 ビュー (過去 30 日間)
古いコメントを表示
?
0 件のコメント
採用された回答
Ameer Hamza
2020 年 9 月 28 日
編集済み: Ameer Hamza
2020 年 9 月 28 日
If this is not a homework question then you can use randi(): https://www.mathworks.com/help/matlab/ref/randi.html instead of rand()
x = randi([0 3], 1, 1000);
If the set have non conseutive integers then you can use randsamples(): https://www.mathworks.com/help/releases/R2020b/stats/randsample.html
randsample([0 1 2 3], 1000, true)
2 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!