Hi, A simple way to get the joint probability matrix for two dimension is using the hist3 function, (read the documentation here ). Let's call your initial matrix nXY nXY=[1 1 1;
2 1 2;
3 1 1]
You will need only the last two columns to count the occurrence of each combination of X and Y (So, we can use nXY(:,2:3)). Also, you need to define a cell array containing all the possible X values and Y values. In this case, just 1 and 2, so:
Xv=[1 2];
Yv=[1 2];
values={Xv Yv};
count=hist3(nXY(:,2:3),'ctrs',values);
p=count/sum(sum(count));
You will get in the estimated joint probabilities in the matrix p. You'll just need to rewrite them in the form you need.
댓글 수: 0
댓글을 달려면 로그인하십시오.