How to generate pseudo random number with fix range ?

Hello.
All I needs is a set of random numbers with the same mu but range between 1 to 9. No fix distribution No fix variance, just the same mu. So, I have try . . .
r=mu*rand([1 9],m,n);
m=30,500 and 1000, n=1
but it does not work T-T
Thankyou for all your kindness and help and I'm so sorry about my broken english ^_^

回答 (2 件)

Wayne King
Wayne King 2012 年 3 月 21 日

0 投票

You can generate uniform random numbers between 1 and 9 with:
R = 1+8*rand(1000,1);

3 件のコメント

Chanon
Chanon 2012 年 3 月 21 日
this syntax can generate uniform random numbers between 1 and 9 but mean were difference each time I generate. I want the same mean (x bar) each time I generate. Thanks.
Wayne King
Wayne King 2012 年 3 月 21 日
You are not going to get a random number generator to produce a sequence that follows some probability law that has the exact same mean each time unless you just generate the same sequence each time.
Oleg Komarov
Oleg Komarov 2012 年 3 月 21 日
Unless the number of trials becomes inf, which is another way of phrasing Wayne's statement.

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

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

質問済み:

2012 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by