distribution - How to plot probability density functions in matlab? -
i need plot probability density function of uniformly distributed matrix from
u = rand (1,1000)
but can't utilize ksdensity function. i've tried this:
term = 1000; u = rand (1,term); x=0:0.001:1; j = 2:term; u_height(j) = u_height(j-1)+((abs(x(j)-u(j))<0.01/2)/0.01)/term; n_height(j) = n_height(j-1)+((abs(x(j)-n(j))<0.01/2)/0.01)/term; end
but it's not plotting correctly
the function ksdensity
should work fine. need specify that range of pdf finite, , utilize box kernel.
u = rand(10000,1); ksdensity(u, 'support', [0 1], 'kernel', 'box');
additionally can approximate pdf using histc
u = rand(10000,1); bins = 0:.05:1; counts = hist(u, bins); p = counts ./ trapz(bins, counts); plot(bins, p);
matlab distribution uniform
No comments:
Post a Comment