Re: Mathematica - How to plot the PDF?



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.
.



Relevant Pages

  • Re: Mathematica - How to plot the PDF?
    ... Density Function (PDF). ... number of elements in bins of some width I set, ... It seems you just want to plot the histogram in the above. ... Decide on which PDF you want to fit (say Normal or Poisson or Binomial ...
    (sci.math.symbolic)
  • Re: The Promise of Forth
    ... Returns the computed median value of a list of numbers, ... number of bins to use for the histogram (more bins brings the computed value ... Association for Computing Machinery Inc., New York, ...
    (comp.lang.forth)
  • Re: Histogram equalization
    ... There is nothing in MATLAB that does accurate histogram matching. ... transform it accurately to the histogram of the second image. ... certain bins with other bins completely empty. ... get a very flat histogram and ALL the bins will be filled up. ...
    (comp.soft-sys.matlab)
  • Problem overlaying data on .gif
    ... I'm plotting some satellite data (latitude, ... every time step) in a 2d histogram (using hist2d from mathworks) so I ... % spaced bins in both dimensions ...
    (comp.soft-sys.matlab)
  • Re: Histogram and Normality test
    ... but the data always fails the normality ... When plotting the histogram with 1000 bins, ... various spikes in the figure. ...
    (comp.soft-sys.matlab)