how can i generate real random numbers?
2 ビュー (過去 30 日間)
古いコメントを表示
hello everyone... i want to generate three real random number between 0 and 1 and must be the total of them equal to 1 if i use this code
a = rand(1); b = 1-a;
what c is ? please help me ...
0 件のコメント
採用された回答
James Tursa
2018 年 3 月 13 日
編集済み: James Tursa
2018 年 3 月 13 日
See this FEX contribution by John D'Errico:
Or this one by Roger Stafford:
その他の回答 (1 件)
John D'Errico
2018 年 3 月 13 日
編集済み: John D'Errico
2018 年 3 月 13 日
First, they are not truly random if you use a computer and an algorithm. They will only be pseudo-random. So they will at best have characteristics that will be consistent with random numbers. But if you want to generate "real" random numbers, then there are ways to do so, sometimes based on things like radioactive decay.
Next, you cannot generate random numbers as you tried. Instead, you want to use a tool like randfixedsum. Find it on the file exchange, James gave you the link already.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!