Random distribution with specific total amount
조회 수: 18 (최근 30일)
이전 댓글 표시
How can I generate the 10 random number with total summation value of 1. The random number should be anything between 0 and 1. Thanks.
댓글 수: 0
채택된 답변
Walter Roberson
2018년 5월 14일
Look in the File Exchange for Roger's randfixedsum()
댓글 수: 2
Walter Roberson
2018년 5월 14일
The only 2 digit decimal numbers that are exactly representable in binary floating point are 0.25, 0.50, and 0.75 . The smallest of these is 0.25, and if you add 10 of those then you would get 2.5, which would exceed your required total of 1.0 . Your task is not possible.
The closest that IEEE 754 double representation gets to 0.28 is 0.2800000000000000266453525910037569701671600341796875
1/100 is not exactly representable in finite binary, exactly the same way that 1/7 is not exactly representable in finite decimal.
You will not be able to do what you want.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!