フィルターのクリア

what should I do with rand() so that the sum of each row should not be greater than one??..

1 回表示 (過去 30 日間)
sani ars
sani ars 2012 年 7 月 18 日
I generated the random numbers from 0 to 1 as follows:
Population = rand(20,3)
now I wants that the sum of each individual row should not be greater than zero
s = sum(Population,2)
how should I restrict each row, generated with rand(), so that the its sum should be b/w 0 and 1??...
The values in each row should come as if I add them up they should not exceed one
plZ answer it.....
  1 件のコメント
Image Analyst
Image Analyst 2012 年 7 月 21 日
"should not be greater than zero" is contradictory with "sum should be b/w 0 and 1". Which is it?

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

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 7 月 18 日
  3 件のコメント
Walter Roberson
Walter Roberson 2012 年 7 月 18 日
randfixedsum(20,3,1,0,1)
sani ars
sani ars 2012 年 7 月 21 日
編集済み: sani ars 2012 年 7 月 21 日
I have tried this one i.e. randfixedsum(20,3,1,0,1)
but this is not giving me sum==1 for each individual row..
Although, the 3rd parameter of the function is set to 1 but it is not giving me the the sum exactly equal to 1 for each individual row..
Plz help me out....

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


Daniel Shub
Daniel Shub 2012 年 7 月 18 日
What about
N = 3;
Population = rand(20,N)/N
  2 件のコメント
sani ars
sani ars 2012 年 7 月 21 日
this is not working:(
Image Analyst
Image Analyst 2012 年 7 月 21 日
Why do you say that? Just look at
theRowSums = sum(Population, 2)
and you'll see that none of the 20 rows has a sum greater than 1.
But you know, we really don't know what you want because you've said three different things!:
  1. "sum of each individual row should not be greater than zero"
  2. "sum should be b/w 0 and 1"
  3. "the sum exactly equal to 1 for each individual row."
There are three totally different things. Please, which one is it? Pick one and stick with it - don't give us a fourth definition.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by