Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to fit the (probability density) histogram of some data with the exponential function, but I am having difficulties. My raw data are in file called datachopped. They are not 'probability density'. I want to fit the probability density histogram of this data with Exp[-x]. So I use the following command:

Histogram[datachopped, Automatic, "PDF", 
 Epilog -> First@Plot[Exp[-x], {x, 0, 4}, PlotStyle -> Red]]

This gives me this plot:

enter image description here

The data is/was here

However, I don't know how well this plot fit, i.e., how to compute the chi-squared, etc. Any help would be appreciated.

share|improve this question

closed as off-topic by Dr. belisarius, m_goldberg, MarcoB, blochwave, Silvia Sep 15 '15 at 9:50

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

Have you looked at EstimatedDistribution? It can use maximum likelihood methods which are typically a much better way to fit a distribution than fitting an approximate PDF obtained by binning. If you go with that, see here for computing standard errors. – Szabolcs Feb 24 '14 at 19:10
If you need to use the binned data for other reasons, then this is a duplicate of this question. Then errors can be obtained as described here under details, or using Sjoerd's answer from my previous link. – Szabolcs Feb 24 '14 at 19:16
So, I used EstimatedDistribution with dist = EstimatedDistribution[data, ExponentialDistribution[a], ParameterEstimator -> {"MaximumLikelihood", Method -> "FindMaximum"}] which gave ExponentialDistribution[0.999997]. It looked great. But then, Show[Histogram[data, Automatic, "ProbabilityDensity"], Plot[PDF[dist, x], {x, 0, 3000}]] showed nothing on the plot! DistributionFitTest[data, dist, {"TestDataTable", All}] gave me Pearson Chi^2 values as Statistics: 121163 and P-value 1.084\times 10^-25972. This means that the exponential distribution is bizarrely off from the data!!! – sjm Feb 24 '14 at 19:35
It's hard to tell what's going wrong without having the data to test with. You can consider uploading it somewhere, e.g. – Szabolcs Feb 24 '14 at 19:45
I'm voting to close this question as off-topic because the data has been removed from the repository and I don't believe the question can be answered without it – Dr. belisarius Sep 14 '15 at 21:55