How to generate a vector of random numbers whose total must be equal to 1?

1 回表示 (過去 30 日間)
balaji
balaji 2020 年 3 月 4 日
コメント済み: James Tursa 2020 年 3 月 4 日
I want to generate a random vector. if i add all the values in the generated vector, its sum should be equal to 1.

回答 (1 件)

James Tursa
James Tursa 2020 年 3 月 4 日
  4 件のコメント
balaji
balaji 2020 年 3 月 4 日
No. I want 1 row having 3 values (column) (for example s = 0.5 0.3 0.2) whose sum should be equal to 1
James Tursa
James Tursa 2020 年 3 月 4 日
... sigh ...
Then transpose the result:
s = randfixedsum(3,1,1,0,1)';

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by