tag:blogger.com,1999:blog-1084292226988033523.post2924604643330558351..comments2024-03-20T21:38:38.876+11:00Comments on Night Walker: Count the frequency of elements in a vector or matrix- part 1Wenbinhttp://www.blogger.com/profile/04027931738228569125noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1084292226988033523.post-14965141502426506652014-12-04T14:25:31.035+11:002014-12-04T14:25:31.035+11:00Hi, simply treat one column as a vector and count ...Hi, simply treat one column as a vector and count the frequency of each elements, the divided by the number of the element in the column.Wenbinhttps://www.blogger.com/profile/04027931738228569125noreply@blogger.comtag:blogger.com,1999:blog-1084292226988033523.post-48313700362295140592014-11-25T03:17:18.000+11:002014-11-25T03:17:18.000+11:00Hello Friends,
I have a m x n matrix. I want to c...Hello Friends,<br /><br />I have a m x n matrix. I want to compute the probability of each element occurring in a column. I want to do it for each column.<br /><br />For instance, suppose we have a 3 x 4 matrix:<br /><br />A = [1 1 3 2; 2 3 0 2; 3 1 0 2];<br /><br />Then, I would like to have the following matrix of probabilities: _P(A) = [ 1/3 2/3 1/3 1; 1/3 1/3 2/3 1; 1/3 2/3 2/3 1];_<br /><br />Here, entries in P(A) are the probabilities of each element within the column.<br /><br />For the 1st column: p(1) = p(2) = p(3) = 1/3<br /><br />For the 2nd column: p(1) = 2/3, p(3) = 1/3<br /><br />For the 3rd column: p(3) = 1/3, p(0) = 2/3<br /><br />For the 4th column: p(2) = 3/3 = 1.<br /><br />Please advise.<br />Anonymousnoreply@blogger.com