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.

  • 2
    $\begingroup$ 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. $\endgroup$ – Szabolcs Feb 24 '14 at 19:10
  • 1
    $\begingroup$ 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. $\endgroup$ – Szabolcs Feb 24 '14 at 19:16
  • $\begingroup$ 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!!! $\endgroup$ – sjm Feb 24 '14 at 19:35
  • $\begingroup$ It's hard to tell what's going wrong without having the data to test with. You can consider uploading it somewhere, e.g. ge.tt $\endgroup$ – Szabolcs Feb 24 '14 at 19:45
  • 2
    $\begingroup$ 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 $\endgroup$ – Dr. belisarius Sep 14 '15 at 21:55