Generating random numbers question
古いコメントを表示
My question involves this assignment:
1. Generate a set of 10,000 random numbers, uniformly distributed between 0 and 100.
I can generate and plot 10000 numbers between 0 and 1 just fine, but Im getting stuck on how to generate between 0 and 100. Ive been using the rand(1) command. Appreciate any help, thanks!
回答 (1 件)
Image Analyst
2013 年 9 月 15 日
Did you happen to look at the very first example in the help for rand? In case you missed it, here it is:
Example 1:
Generate values from the uniform distribution on the interval [a,b]:
r = a + (b-a).*rand(100,1);
For you, of course, a = 0 and b = 100. And 100 would be 10,000, so it becomes:
r = 100.*rand(10000,1);
3 件のコメント
Azzi Abdelmalek
2013 年 9 月 15 日
[Nathan commented]
ok thanks. I also had a question on this part: Generate a set of 10,000 normally distributed random numbers with mean of 50 and standard deviation of 20
Im having trouble coding this out while keeping it in the same script as the previous question
Image Analyst
2013 年 9 月 16 日
編集済み: Image Analyst
2013 年 9 月 16 日
There is a randn() function that I'm quite confident you'll have no trouble figuring out. The fact that you are calling rand() earlier in the script is of no consequence. You can use different variable names for each set of random numbers of course. So, what trouble are you having, keeping the two in the same script?
Walter Roberson
2013 年 9 月 16 日
Suppose you have a book that is balanced right over the X axis, equal parts to the left and right. Where is the (vertical) mean position of the book? Now suppose you move the book 10 cm to the right. Where is the (vertical) mean position of the book now?
カテゴリ
ヘルプ センター および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!