how to generate a uniform random variable with mean zero and variance ten?
조회 수: 4 (최근 30일)
이전 댓글 표시
Dear sir/madam,
I need to generate a uniform random variable with mean 0, and variance 10 for my project. How could I generate this in matlab? Looking forward to hearing from you soon.
Thanking you, BSD
댓글 수: 0
답변 (2개)
Daniel Shub
2011년 8월 5일
((2*rand)-1)*sqrt(12/4)*sqrt(10)
The ((2*rand)-1) gives you a random variable with zero mean and a variance of 4/12. The rest scales it to a variance of 10.
댓글 수: 0
Praveen Pawar
2017년 11월 27일
Below expression will generate 1000 random numbers of any mean and standard deviation. And SD = sqrt(var)
y = standard_deviation.*randn(1000,1) + mean
댓글 수: 1
Steven Lord
2017년 11월 27일
The line of code you've written is fine for solving a question about generating random numbers, but it will not solve the original question.
Part of that original question, with some emphasis added, was "I need to generate a uniform random variable". The randn function generates normally distributed pseudorandom numbers.
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!