Create a multi value variable
이전 댓글 표시
Hi all:
I am trying to create a random variable that can take 5 values from 0 to 4 with the following probability distribution p0 = 0.36 P1 = 0.16 P2 = 0.16 P3 = 0.16 P4 = 0.16
Could you please help me in this.
답변 (1개)
Roger Stafford
2014년 5월 19일
To get you started here's a hint in the form of another question. In the following code what are all the possible values of the variable 's' and what are their respective probabilities?
c = [0.21,0.32,0.65,0.87];
r = rand;
s = sum(r<c);
댓글 수: 2
Mahmoud
2014년 5월 19일
Roger Stafford
2014년 5월 20일
편집: Roger Stafford
2014년 5월 20일
No, you should try running that code repeatedly and see. Maybe it will give you some ideas.
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!