1
$\begingroup$

I am trying to obtain the optimal probability distribution function to the following data.

My attempt:

data = Import["data_prob_new.dat", "Table"];
P00 = Histogram[Flatten[data], Automatic, "Probability", 
ChartStyle -> Gray, ChartBaseStyle -> EdgeForm[None], 
ImageSize -> 500]
fit = FindDistributionParameters[Flatten[data], 
LaplaceDistribution[a, b]]; 
a0 = a /. fit[[1]];
b0 = b /. fit[[2]];
lim = 1000;
t0 = Plot[PDF[LaplaceDistribution[a0, b0], x], {x, a0, lim}, 
PlotStyle -> {Blue, Thick}, PlotRange -> All];
P0 = Show[{P00, t0}, Frame -> True, Axes -> False, 
FrameStyle -> Thick, PlotRange -> {{0, All}, {-0.001, All}}, 
PlotRangePadding -> 0, PlotRangeClipping -> True]

enter image description here

As we can see, the Laplace probability distribution fails to smoothly fit the tail of the histogram. My question: How can we obtain the best fit (type of distribution) for this histogram?

$\endgroup$
  • 2
    $\begingroup$ The data are not distributed Laplace. $\endgroup$ – Alan Nov 3 '18 at 12:07
  • 1
    $\begingroup$ Gamma distribution might be better $\endgroup$ – mikado Nov 3 '18 at 12:46
  • 1
    $\begingroup$ Try using the EstimatedDistribution function, with a range of PDFs. Looks a bit like the exponential distribution to me. $\endgroup$ – GerardF123 Nov 3 '18 at 15:21
  • 1
    $\begingroup$ There is no "optimal" because you haven't stated what kind of process generated the data. You just have data for which you'd like a reasonable and more compact description such as "Exponential distribution with parameter $\lambda$". Also, you want "PDF" rather than "Probability" to make the histogram and probability density match in scale. $\endgroup$ – JimB Nov 3 '18 at 16:51
  • 1
    $\begingroup$ "no good" ???? See answer below. $\endgroup$ – JimB Nov 3 '18 at 17:49
4
$\begingroup$

Given that you just have data and an urge to fit a parametric probability distribution, the quality of the fit is in the eye of the beholder. Here's the fit with the gamma distribution (suggested by @mikado) (which I think you'll be hard-pressed to find a better fit):

P00 = Histogram[data, Automatic, "PDF", ChartStyle -> Gray, 
   ChartBaseStyle -> EdgeForm[None], ImageSize -> 500, 
   PlotRange -> All];
fit = FindDistributionParameters[data, 
   GammaDistribution[α, β, γ, μ]];

t0 = Plot[PDF[GammaDistribution[α, β, γ, μ] /. fit, x], {x, μ0, Max[data]},
   PlotStyle -> {Blue, Thick}, PlotRange -> All, PlotPoints -> 100];
P0 = Show[{P00, t0}, Frame -> True, Axes -> False, FrameStyle -> Thick,
  PlotRange -> {{0, All}, {0, All}}, PlotRangePadding -> 0, PlotRangeClipping -> True]

Histogram and fit with gamma distribution

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Just a comment: Inside the Histogram[...] you changed the option from "Probability" to "PDF". Why? What if we want to plot probability instead of PDF and find the best fit of it? $\endgroup$ – Vaggelis_Z Nov 3 '18 at 21:24
  • $\begingroup$ You were estimating the parameters of a probability distribution function (pdf) and using the PDF function to display the probability distribution function. For a histogram to match scales, you need the "PDF" option. About the second question I answer with a question: Why would you want a probability scale that's associated with an arbitrary sample size and arbitrary layout of the bins? $\endgroup$ – JimB Nov 3 '18 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.