0
$\begingroup$

I have a dataset that is clearly the mixture of 3 known distributions which can be generated as follows:

data1 = RandomVariate[NormalDistribution[2130, 80], 9000];
data2 = RandomVariate[UniformDistribution[{2250, 4050}], 6000];
data3 = RandomVariate[NormalDistribution[4100, 90], 3000];

which when overlapping the histograms with my real data, "mydata" reveals:

Histogram[{mydata, data1, data2, data3}, {"Raw", 2000}, 
PlotRange -> {{1500, 4500}, {0, 250}}]

Overlap Histograms

where the light yellow histogram is my real data. To drive the point that my dataset is a mixture distribution of a two normal and a uniform distribution even further, here is histogram comparison of the distributions mixed compared to my real data:

Histogram[{mydata, Flatten[{data1, data2, data3}]}, {"Raw", 2000}, 
PlotRange -> {{1500, 4500}, {0, 250}}]

mixture

However, when I go to fit my real data with a mixture distribution with initialized parameters of the generated data, my uniform distribution is being bullied out:

params = FindDistributionParameters[mydata, 
MixtureDistribution[{g, h, i}, {NormalDistribution[a, b], 
UniformDistribution[{c, d}], 
NormalDistribution[e, f]}], {{g, .5}, {h, .3}, {i, .2}, {a, 
2130}, {b, 80}, {c, 2250}, {d, 4050}, {e, 4100}, {f, 90}}]

the results are

{g -> 0.494885, h -> 0.000655526, i -> 0.504459, a -> 2143.23, 
b -> 79.4785, c -> 2250., d -> 8414.1, e -> 3491.59, f -> 659.049}

where the weight of the uniform distribution, h, is being reduced to nothing. This is the resulting fit:

p1 = Histogram[mydata, {"Raw", 2000}, PDF, 
PlotRange -> {{0, 6000}, {0, .003}}];

p2 = Plot[
PDF[MixtureDistribution[{g, h, i}, {NormalDistribution[a, b], 
UniformDistribution[{c, d}], NormalDistribution[e, f]}]][x] /. 
params, {x, 0, 5000}, PlotRange -> {{0, 6000}, {0, .003}}]

Mixture Distribution PDF fit

My end game is to obtain an analytical function for the mixture PDF, but I'll face that hurdle when I get there. Any assistance would be greatly appreciated.

P.S. I also added

ParameterEstimator -> {"MaximumLikelihood", 
Method -> {"NMaximize", PrecisionGoal -> 1000, 
AccuracyGoal -> 1000, MaxIterations -> 10000}

as an argument in the FindDistributionParameters to no avail.

Edit: Here is a pastbin of "mydata".

$\endgroup$
  • 2
    $\begingroup$ Not sure what's going on because if I replace mydata with mydata = Join[data1, data2, data3], then the weights work out fine. Can your data be made available? $\endgroup$ – JimB Apr 13 '18 at 0:45
  • $\begingroup$ Please post your data on Pastebin if it is too large to include in your question. $\endgroup$ – J. M. will be back soon Apr 13 '18 at 2:21
  • $\begingroup$ Hmmm that's strange, I'll follow up tomorrow when I have the data on hand. $\endgroup$ – tquarton Apr 13 '18 at 4:38
  • $\begingroup$ I've edited my post with a pastebin link of "mydata". Thanks for taking a look at it. $\endgroup$ – tquarton Apr 13 '18 at 18:09
  • 2
    $\begingroup$ Here's why you got the results you did: mydata has a MinMax of {0.9, 8414.1} and the combination of data1, data2, and data3 has a MinMax of {1767, 4391} (at least with one random realization). The point is that the 50 or so points that are way outside of the simulated data are causing the results you see. Take those 50 points away and all of the parameters are about what you expect. How to fix that? That will be in my next comment - after lunch. $\endgroup$ – JimB Apr 13 '18 at 18:43

Your Answer

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

Browse other questions tagged or ask your own question.