필터 지우기
필터 지우기

bounded random numbers with a certain sum

조회 수: 2 (최근 30일)
Seldeeno
Seldeeno 2017년 5월 5일
답변: Image Analyst 2017년 5월 5일
Hello
I am trying to see how I can generate 5 random numbers, each between 0-2, and the sum is given. (I need this as a part of my bigger matrix that is used motivate my sin function later in the simulation.)
Thanks

답변 (1개)

Image Analyst
Image Analyst 2017년 5월 5일
This generates m random n-element column vectors of values, [x1;x2;...;xn], each with a fixed sum, s, and subject to a restriction a<=xi<=b. The vectors are randomly and uniformly distributed in the n-1 dimensional space of solutions. This is accomplished by decomposing that space into a number of different types of simplexes (the many-dimensional generalizations of line segments, triangles, and tetrahedra.) The 'rand' function is used to distribute vectors within each simplex uniformly, and further calls on 'rand' serve to select different types of simplexes with probabilities proportional to their respective n-1 dimensional volumes. This algorithm does not perform any rejection of solutions - all are generated so as to already fit within the prescribed hypercube.

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by