title: Matlab - computing the probability of each element within a vector
body: <p>I am having a vector <code>y</code> which may have the following form:</p>
  
  <p><code>y = [1 1 1 1 2 2 2 2 1 1 3 3 4 5]</code></p>
  
  <p>And I want to attach a probability to each element within <code>y</code> as it would've been generated by a random variable. In this case, the element 1 would have the probability 6/14, the element 2 would have the probability 4/14, the element 3 the value 2/14 and the elements 4 and 5 the value 1/14.</p>
  
  <p>And basically, the result should look like:</p>
  
  <p><code>prob_y = 1/14 * [6 6 6 6 4 4 4 4 6 6 2 2 1 1]</code></p>
  
  <p>Is there a way of doing this without any <code>for</code> or <code>while</code> loops?</p>