Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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

Right now I am using pdfplot.m file to plot my empirical pdf, however when I want to compare the 3 distributions by using 'hold on', then firstly its not working and secondly all the distributions are in same color. Thanks!

Also, I don't want to plot cdf or histogram.

share|improve this question

2 Answers

up vote 2 down vote accepted

the problem is that histc plots bars instead of, say lines; the bars are plotted over one another. you should edit pdfplot to plot lines instead. look for the hist command and alter it.

share|improve this answer
Thanks! It is solved now, though with hist only. – Pupil Sep 29 '10 at 22:14

I would suggest using the ksdensity function. In the following example I compare the pdf of the data in column 1 of matrix 1 with the pdf of the data in column 2 of matrix 2:

[f,x] = ksdensity(mat1(:,1));
plot(x,f,'--b');hold
[f,x] = ksdensity(mat2(:,2));
plot(x,f,'--m')
legend('Data 1 pdf', 'Data 2 pdf');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.