How can I set the values of matrix in interval <a, b>?
12 ビュー (過去 30 日間)
古いコメントを表示
Generate a matrix Ru of pseudo-random floating point values from a uniform distribution, a matrix Ri of pseudo- random integer
values from a uniform distribution and a matrix Rn of pseudo-random values from a normal distribution. Let the size of all
matrices be M x N. Let the expected value of Rn be m = 8 and variance v = 3. Let the values of Ru an Ri be from the interval < a,
b > = < 4, 9 >.
Rn = rand( M, N ) ;
Ru = randn( M, N) ;
Ri = randi( [a, b], M, N ) ; % here I know how to set the interval <a, b>
2 件のコメント
Stephen23
2022 年 12 月 4 日
編集済み: Stephen23
2022 年 12 月 4 日
Original question by Ihor retrieved from Google cache:
How can I set the values of matrix in interval <a, b>?
Generate a matrix Ru of pseudo-random floating point values from a uniform distribution, a matrix Ri of pseudo- random integer
values from a uniform distribution and a matrix Rn of pseudo-random values from a normal distribution. Let the size of all
matrices be M x N. Let the expected value of Rn be m = 8 and variance v = 3. Let the values of Ru an Ri be from the interval < a,b > = < 4, 9 >.
Rn = rand( M, N ) ;
Ru = randn( M, N) ;
Ri = randi( [a, b], M, N ) ; % here I know how to set the interval <a, b>
Rik
2022 年 12 月 4 日
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
採用された回答
DGM
2022 年 12 月 4 日
編集済み: DGM
2022 年 12 月 4 日
Start with:
m = 500;
n = 500;
rrange = [4 9];
mn = 8;
vr = 3;
% uniform distribution with a specified range
Ru = rrange(1) + range(rrange)*rand(m,n);
[min(Ru(:)) max(Ru(:))]
% normal distribution with specified mean, variance
Rn = mn + sqrt(vr)*randn(m,n);
[mean(Rn(:)) var(Rn(:))]
% discrete uniform random integers
Ri = randi(rrange,m,n);
[min(Ri(:)) max(Ri(:))]
3 件のコメント
DGM
2022 年 12 月 4 日
oof. I forgot that was in stats toolbox.
Ru = rrange(1) + (rrange(2)-rrange(1))*rand(m,n);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!