Re: Mathematica - How to plot the PDF?
- From: Dave <nowhere@xxxxxxxxxxx>
- Date: Wed, 21 Nov 2007 01:50:19 +0000
Nasser Abbasi wrote:
On Nov 20, 4:02 pm, Dave <nowh...@xxxxxxxxxxx> wrote:I have some experimental data and would like to plot the Probability
Density Function (PDF). I've tried using 'BinCounts', to determine the
number of elements in bins of some width I set, then use ListPlot:
ListPlot[BinCounts[data,0.01],DataRange->{Min[data],Max[data]}]
This works, but it has a few problems.
1) It is hard to get a nice smooth curve. Make the bins too wide and
there are not enough points on the horizontal axis. Make them too narrow
and there are too few points in each bin. It seems hard to get a happy
medium. I can't help feeling that putting them into bins is not the best
way.
2) It is slow. I think this is mainly because I am using a large amount
of data to get a smooth curve.
Any suggestions of a better way?
well, first if it is discrete data, then it is normally called pmf
(prob. mass function), pdf is used for continuous data.
Thank you. I had never herd of that!
It seems you just want to plot the histogram in the above. Notice
that Mathematica histogram is not a 'probability' type histogram like
say in R, i.e. the areas have to add to 1, so this part you have to do
by yourself, I have a function I can email you when I go home that
takes a list of data and generate a 'probability' histogram (i.e.
areas add to 1).
Yes, you are right - i do want the histogram. I would appreciate a copy of your function. I think you have my email.
But what I think you want is to fit a probability model to your data?
Yes, that is one thing I would like to do. I've never tried using anything other than Fit to fit polynomials before.
However, I would like to plot the actual data as a histogram.
We have some data, which someone said would be a uniform distribution. I did not think that so and it looks like a normal distribution to me. But I would like to plot it, and show him the actual data, rather than just a line of best fit.
Obviously, plotting the original data, AND a line of best fit on the same graph would be nice.
Decide on which PDF you want to fit (say Normal or Poisson or Binomial
or whatever), then estimate the parameters of this model from your
data, (use maximum liklehood),
Any suggestions how? I've only ever used Mathematica before to fit data to a polynomial, with something like
Fit[data,{1,x,x^2},x]
then simply use Mathematica
Plot[PDF[model_you_selected]] using the parameters you estimated. and
see how good the fit it.
hth
Nasser
Thank you Nasser.
.
- Follow-Ups:
- Re: Mathematica - How to plot the PDF?
- From: Nasser Abbasi
- Re: Mathematica - How to plot the PDF?
- From: Nasser Abbasi
- Re: Mathematica - How to plot the PDF?
- References:
- Mathematica - How to plot the PDF?
- From: Dave
- Re: Mathematica - How to plot the PDF?
- From: Nasser Abbasi
- Mathematica - How to plot the PDF?
- Prev by Date: Re: Mathematica - how best to transpose x and y axes on graph?
- Next by Date: Re: Mathematica - how best to transpose x and y axes on graph?
- Previous by thread: Re: Mathematica - How to plot the PDF?
- Next by thread: Re: Mathematica - How to plot the PDF?
- Index(es):
Relevant Pages
|
|