Vector question help?

1 回表示 (過去 30 日間)
idan
idan 2022 年 7 月 9 日
コメント済み: Karim 2022 年 7 月 9 日
hello,
A vector with 25 integer values ​​that are randomly drawn in a normal distribution Standard ("randn" and "round" functions must be used).
help from someone?
Thanks.
  1 件のコメント
John D'Errico
John D'Errico 2022 年 7 月 9 日
PLEASE STOP ASKING THE SAME QUESTION. You asked it yesterday. It got an answer. You ACCEPTED the answer. So why ask it again today?

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

回答 (1 件)

Karim
Karim 2022 年 7 月 9 日
編集済み: Karim 2022 年 7 月 9 日
% this step creates a vector with 25 normal distributed random values
MyVector = randn( 1,25 )
MyVector = 1×25
-0.4239 -1.5898 -0.4024 0.3069 -0.7501 1.3158 -1.0187 -1.4043 -1.6596 -0.0980 0.7049 -0.3003 1.6321 0.5295 -0.1080 -1.7873 -0.9262 -1.5933 -0.0804 1.7420 0.6466 0.0237 -1.2713 -1.2126 -1.7791
% if you want to round these values to obtain integers you can do:
MyRoundVector = round( MyVector )
MyRoundVector = 1×25
0 -2 0 0 -1 1 -1 -1 -2 0 1 0 2 1 0 -2 -1 -2 0 2 1 0 -1 -1 -2
However, note that (as John indicated) after the rounding the vector no follows a normal distribution. This vector simply contains the rounded values.
  2 件のコメント
John D'Errico
John D'Errico 2022 年 7 月 9 日
編集済み: John D'Errico 2022 年 7 月 9 日
The vector you have shown how to generate does NOT follow a normal distribution. Once rounded, the sample no longer comes from a normal distribution. That there is no answer to the question now asked multiple times by the poster is a better response.
Karim
Karim 2022 年 7 月 9 日
Indeed, thank you for pointing this out :) I updated the answer and added a few comments rather than deleting it.

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

カテゴリ

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