3
$\begingroup$

I have a number of distributions that I am adding to result in one summarized distribution, e.g.:

distSum={0.167467 E^(-(1/2) (-21.5 + x)^2), 0.160772 E^(-(1/2) (-19.7 + x)^2),
  0.233762 E^(-(1/2) (-21.7 + x)^2), 
 0.0930353 E^(-(1/2) (-21.9 + x)^2), 
 0.373293 E^(-(1/2) (-22.4 + x)^2), 0.126876 E^(-(1/2) (-19. + x)^2), 
 0.348056 E^(-(1/2) (-22.7 + x)^2), 0.393082 E^(-(1/2) (-21.4 + x)^2),
  0.35867 E^(-(1/2) (-20.9 + x)^2), 0.383496 E^(-(1/2) (-22.3 + x)^2)}

Now I would like to have some information and lists from the single distSum. E.g., what is the Mean/Median/etc of distSum? Also, I'd like to extract a sample from distSum, but I can't simply use RandomSample on distSum. I know how to apply these statistical parameters on lists, but as this is a function, and not a list, I don't know how to get these parameters.

enter image description here

$\endgroup$
  • $\begingroup$ ...so a bunch of Gaussians? $\endgroup$ – J. M. is away Aug 5 '16 at 16:36
  • $\begingroup$ In this case yes, but is just an example. Could also be others. $\endgroup$ – Mockup Dungeon Aug 5 '16 at 16:38
  • $\begingroup$ @Karsten7. No – but I just tried NExpectation, as I think that's what you were referring to. No result. If I could get a list from distSum, then I could basically apply what I need. But I don't know, how to transfer this distribution function in a list that would basically produce the same histogram as the function. $\endgroup$ – Mockup Dungeon Aug 5 '16 at 16:50
  • 3
    $\begingroup$ None of these functions are probability distributions as none of them integrate to 1 and the integral of the sum isn't 1 either. So why do you call them distributions? $\endgroup$ – JimB Aug 5 '16 at 17:10
  • 1
    $\begingroup$ Rather than asking for more precise statistical terms, I'd say we're really asking for more or clarifying information so that we can understand the question better and provide you with an appropriate answer. $\endgroup$ – JimB Aug 6 '16 at 5:11
4
$\begingroup$

You can define a MixtureDistribution thus

Integrate[distSum, {x, -∞, ∞}] // Chop
Integrate[x distSum, {x, -∞, ∞}] // Chop
means = %/%%
weights = %%%/Total[%%%]
dist = MixtureDistribution[weights, NormalDistribution[#, 1] & /@ means]

and apply most of the statistical functions to it

Through[{Mean, Variance, Median, RandomReal}[dist]]
(* {21.6074, 1.94362, 21.7081, 21.8625} *)
$\endgroup$
2
$\begingroup$

Here is how you can apply the same principles used in this answer to your problem:

distSum = {0.167467 E^(-(1/2) (-21.5 + x)^2), 0.160772 E^(-(1/2) (-19.7 + x)^2), 
   0.233762 E^(-(1/2) (-21.7 + x)^2), 0.0930353 E^(-(1/2) (-21.9 + x)^2), 
   0.373293 E^(-(1/2) (-22.4 + x)^2), 0.126876 E^(-(1/2) (-19. + x)^2), 
   0.348056 E^(-(1/2) (-22.7 + x)^2), 0.393082 E^(-(1/2) (-21.4 + x)^2), 
   0.35867 E^(-(1/2) (-20.9 + x)^2), 0.383496 E^(-(1/2) (-22.3 + x)^2)};

dist = ProbabilityDistribution[
        Plus @@ distSum, {x, -Infinity, Infinity}, Method -> "Normalize"];

mean = NExpectation[x, x \[Distributed] dist]

$\ $ 21.6074

variance = Expectation[(x - mean)^2, x \[Distributed] dist] // Chop

$\ $ 1.94362

Plot[PDF[dist, x], {x, 12, 30}, PlotRange -> All]

Out

RandomVariate[dist, 10]

$\ $ {20.7231, 21.2831, 20.6987, 22.486, 22.7043, 25.5388, 21.5406, 21.9175, 20.5078, 21.9182}

$\endgroup$
  • $\begingroup$ I see, thanks, Karsten. $\endgroup$ – Mockup Dungeon Aug 6 '16 at 5:35

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.