How can I display the empirical pdf of my 100x1 vector data in Matlab?

I have data that is a 100x1 vector. How can I display its empirical pdf file in Matlab? Also, if I want to compare the pdf of three vectors on the same graph, then how do I do this?

Now I use the pdfplot.m file to build my empirical pdf, however, when I want to compare 3 distributions using 'hold on', then, firstly, it does not work, and secondly, all distributions are the same color. Thank!

EDIT: I do not want to build cdf.

+3
source share
2 answers

hist :

hist(data)

or, if you want more control over how it is presented, use:

[n,x] = hist(data);
plot(x,n,'rx-'); %# just an example, plot the pdf with red x and a line, 
                 %# instead of bars
figure;
plot(x, cumsum(n)/sum(n)); %# plot the CDF
+4
source

What you are looking for is kernel density estimation (also known as parzen windows). It is implemented in KSDENSITY in the Statistics toolbar:

data = randn(100,1);
ksdensity(data)

alt text

The above Wikipedia article has a MATLAB example using the FEX function representation

+11
source

Source: https://habr.com/ru/post/1767230/


All Articles