# Plot empirical vs theoretical distributions in MATLAB

I have some data that I would like to compare with a theoretical distribution for which I know the parameters. How do I plot the empirical pdf against the theoretical pdf? Perhaps I should add that I would like to plot two continuous pdfs.

Edit:

I am sorry if this problem is more related to Stack Overflow. I actually thought about posting it there but finally changed my mind.

I know that I can use ecdfand ksdensity in MATLAB for example. But what I am looking for is if there exists some better tool to compare pdfs as I am having problem to get two pdfs to overlap. So visual comparison is not that good. The same also goes for CDFs actually, for example plots don't want to overlap when I have shifted distributions.

• Welcome to the site, @universalis. Are you interested in ways of thinking about how to visualize these, or do you just need help w/ MATLAB code? Note that the latter would be off-topic for CV (see our help page), but on-topic on Stack Overflow. If the former, please edit to clarify; if the latter, flag your Q & we'll migrate it for you (please don't cross-post, though). – gung - Reinstate Monica Jul 9 '13 at 20:16
• Thank you for clarifying your question, @universalis. It doesn't sound like you want programming advice, but rather to think about how to better visualize & understand these pdfs. That means your question belongs here. +1 – gung - Reinstate Monica Jul 9 '13 at 23:40
• @gung Thank you. You are right, I know how to do this programmatically but fail to understand the outcome of the plots sometimes. Hopefully someone can bring clarity to this. – universalis Jul 10 '13 at 7:02
• Would it be possible to post your data as part of your question (if it's not too large), @universalis, or perhaps the plots that you're unsatisfied w/, & maybe some summary statistics (eg, means & sds, or whatever would give people a preliminary sense of the data numerically)? – gung - Reinstate Monica Jul 10 '13 at 14:01
• I'm not entirely clear on the difficulties you mention with the displays you're already aware of. Could you put up some examples illustrating what the difficulty is (or given your rep, upload them to imgur and put the links in your post - sooner or later someone else will incorporate them for you) – Glen_b -Reinstate Monica Jul 11 '13 at 3:06