How to draw probability density function in MatLab?

后端 未结 4 1970
花落未央
花落未央 2021-01-03 00:13
x = [1 2 3 3 4]
cdfplot(x)

After Googling, I find the above code will draw a cumulative distribution function for me in Matlab.
Is there a simp

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 00:35

    If you want a continuous distribution function, try this.

    x = [1 2 3 3 4]
    subplot(2,1,1)
    ksdensity(x)
    axis([-4 8 0 0.4])
    
    subplot(2,1,2)
    cdfplot(x)
    grid off
    axis([-4 8 0 1])
    title('')
    

    Which outputs this. enter image description here

    The Cumulative Distribution Function is on the bottom, the Kernel Density Estimate on the top.

提交回复
热议问题