Random number in a specific range
이전 댓글 표시
Hello,,I wanna generate random numbers from range for example [-0.2,0.2] using matlab functions like randn or sth. thanks in advance.
채택된 답변
추가 답변 (2개)
Oleg Komarov
2012년 5월 13일
0 개 추천
You can scroll down the documentation of randn for an example.
EDIT You don't even need to scroll down.
댓글 수: 2
Walter Roberson
2012년 5월 14일
The closest I see in the randn documentation is for a given mean and standard deviation. Nothing about a given range. Not for randn.
http://www.mathworks.com/help/techdoc/ref/randn.html
Oleg Komarov
2012년 5월 14일
Right, on the FEX there are contributions with random generators from truncated normal.
Walter Roberson
2012년 5월 14일
0 개 추천
It is not possible to construct a normal distribution over a restricted range. By definition a normal distribution must have an infinite tail in both directions.
If you need something that is much like a normal distribution but is defined over a limited range, then consider using a beta distribution.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!