Creating a matrix with binomial distribution in elements.

조회 수: 2 (최근 30일)
Shane Kosir
Shane Kosir 2016년 10월 18일
편집: Massimo Zanetti 2016년 10월 19일
How can I create a 6 × 6 matrix with P (Xi = j − 1) in the (i, j)-position where Xi has the binomial distribution with parameters n = i−1 and p = 1/4.

답변 (1개)

Massimo Zanetti
Massimo Zanetti 2016년 10월 19일
Check for "binornd" function in Matlab docs
  댓글 수: 2
Shane Kosir
Shane Kosir 2016년 10월 19일
I know that function, but how can you create a matrix and specify that the elements are the binornd function/
Massimo Zanetti
Massimo Zanetti 2016년 10월 19일
편집: Massimo Zanetti 2016년 10월 19일
So you don't need to extract a random number, instead you need to compute the probability. So, it is:
N=repmat((0:5)',1,6);
K=N';
P=1/4;
R = binopdf(K,N,P)
Notice that the triangular upper part is null, because there is 0 probability to get K successes if the numer of trials N is less than K....

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by