How could i generate 10000 samples of a random variable uniformly distributred in(0,1)??

Dear Sir/Madam, How could i generate 10000 samples of a random variable uniformly distributred in(0,1)??

4 件のコメント

Purushottama Rao
Purushottama Rao 2015 年 8 月 19 日
編集済み: Purushottama Rao 2015 年 8 月 19 日
Are you lookig for somethinglike
rand(10000,1)
HARI  PRASAD
HARI PRASAD 2015 年 8 月 19 日
can i use X=rand(1,10000);
Walter Roberson
Walter Roberson 2015 年 8 月 19 日
Yes.
i have generated 2 random variables X and Y uniformly distributed in (0 1) ,10000 samples each.
now i have to find R(i)= square root of sum of the squares of X and Y.
Is this below code correct for the problem
i=0:1:10000;
R(i)= sqrt((X(i).^2) + (Y(i).^2));
while running i get error on the last line which is as below
Subscript indices must either be real positive integers or logicals.

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

回答 (1 件)

Purushottama Rao
Purushottama Rao 2015 年 8 月 19 日
編集済み: Purushottama Rao 2015 年 8 月 19 日
In your code,loop should start form 1. i=1:1:1000
However inorder to acheieve what you have wanted, you may not need a loop.
X= rand(1,10000);
Y=rand(1,10000);
k=sqrt(X.^2+Y.^2)
k is the result

カテゴリ

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

質問済み:

2015 年 8 月 19 日

編集済み:

2015 年 8 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by