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 CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by