Generate a group of random number

조회 수: 2 (최근 30일)
hongtao xu
hongtao xu 2023년 11월 27일
답변: Torsten 2023년 11월 27일
hello
I want to generate 20000 random numbers in the range of (0,1) and it conforms to a normal distribution with a standard deviation of 0.5 and a variance of 1.
please help me
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 11월 27일
"with a standard deviation of 0.5 and a variance of 1."
Yeah, that's not possible.
Is one of the properties supposed to be mean/average?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2023년 11월 27일
Try this and see if it works for your purposes.
r = 0.5 * randn(20000, 1);
histogram(r);
grid on;
theMean = mean(r)
theMean = -0.0011
stDev = std(r)
stDev = 0.5051
x = r - 0.5; % Mean center the data
% Do a KS test for normal distribution.
h = kstest(x)
h = logical
1
% Do a lillie test for normality.
h = lillietest(x)
h = 0

추가 답변 (1개)

Torsten
Torsten 2023년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by