I have a vector y , which can look like this:
y = [1 1 1 1 2 2 2 2 1 1 3 3 4 5]
And I want to bind the probability to every element inside y , since it would be generated by a random variable. In this case, element 1 will have a probability of 6/14, element 2 will have a probability of 4/14, element 3 will have a value of 2/14, and elements 4 and 5 will have a value of 1/14.
And basically, the result should look like this:
prob_y = 1/14 * [6 6 6 6 4 4 4 4 6 6 2 2 1 1]
Is there a way to do this without for or while chains?
matlab
Simon Aug 03 2018-11-21T00: 00Z
source share