How do I generate a random number with normal distribution
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to generate a random matrix with normal distribution between -10 and 10. I cannot use randn() because it has no boundaries. Is there any other to generate such matrix??
댓글 수: 0
채택된 답변
Star Strider
2019년 3월 30일
This is called a truncated distribution. While you are correct that it is no longer strictly a normal distribution (that extends to infinity to either side of the mean), you can nevertheless define it. The extended discussion is in the truncate (link) documentation section in Truncate a Probability Distribution (link).
For your Question, this would be:
pd = makedist('Normal')
t = truncate(pd,-10,10)
r = random(t,10000,1);
Experiment to get the result you want.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
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!