Determining probability mass function of random variable

后端 未结 6 647
一整个雨季
一整个雨季 2021-01-13 04:01

If we have a discrete random variable x and the data pertaining to it in X(n), how in matlab can we determine the probability mass function pmf(X)?

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 04:33

    The following excerpt from the MATLAB documentation shows how to plot a histogram. For a discrete probability function, the frequency distribution might be identical with the histogram.

    x = -4:0.1:4;
    y = randn(10000,1);
    n = hist(y,x);
    pmf = n/sum(n);
    plot(pmf,'o');
    

    Calculate the sum of all the elements in every bin. Divide all bins by the sum to get your pdf. Test your pdf by adding up all elements. The result must be one.

    Hope I'm right with my statements. It's a long time since ...

提交回复
热议问题