I have a custom distribution created to model some experimental observations. While too complicated to include in this question, I can provide an example and some illustrations to convey a sense of it.
Take the following as representing the PDF
of the distribution:
pdf = (0.334336 (E^(2.56822 (-4.1816 - Log[x])) Erfc[
3.54409*10^7 (-4.1816 - Log[x])] +
E^(0.904055 (4.1816 + Log[x])) Erfc[
3.54409*10^7 (4.1816 + Log[x])]))/x;
Which one can readily plot:
Plot[pdf, {x, 0, 0.05}, PlotRange -> {All, {0, 100}}]
Defining the distribution, dist
as :
dist = ProbabilityDistribution[pdf, {x, 0, ∞}]
I can generate RandomVariates
of dist
and plot them in a Histogram
:
Histogram[RandomVariate[dist, 10^5], {0, 0.05, 0.0005}, "PDF",
ImageSize -> 300, PlotRange -> {All, {0, 100}}]
You can see that the histogram and plot of the PDF look pretty similar. So far so good.
I have conjectured that if one takes sufficient observations the data will eventually converge to an exponential distribution. So, I thought to estimate an exponential distribution from (in this case) generating a bunch of random data using the original distrubtion.
Plot[{
PDF[EstimatedDistribution[RandomVariate[dist, 10^4],
ExponentialDistribution[λ]], x],
pdf}, {x, 0, 0.05},
ImageSize -> 300, PlotRange -> {All, {0, 100}}]
I like this, BUT this leads to my first question:
Where do all those squiggles in the PDF of the exponential distribution come from?
Take a closer look:
Does this seem normal? Shouldn't I get a smooth curve? Hopefully someone will have an insight, but this got me wondering and led me to a second and maybe more interesting question:
Does Mathematica have a way to directly fit one distribution to another without (in the above case) the intermediate step of generating a set of random variates first?
dist
is defined easily, it would've been better to do that instead of noting everywhere that the code won't run... it looks much better now :) $\endgroup$