2
$\begingroup$

What I would like to do is create a mixture distribution that has a specified mean by varying one parameter in the distribution. To do this I've written the following code;

dist := MixtureDistribution[{0.1,0.9}, {UniformDistribution[{39.3, 40.5}],
TruncatedDistribution[{40.5, 104}, NormalDistribution[a, 11.4]]}]

NSolve[Mean[dist] == 82.63344, a]

Which just returns a "PolynomialGCD::lrgexp" error.

What I ended up doing is putting values in using trial and error until it gave me the correct mean (so it does have a solution). Is there any way so solve this equation without resorting to trial and error?

I think the TruncatedDistribution / Mean combination is what is causing problems. When I remove the TruncatedDistribution NSolve quickly returns a solution. The following link discussed this issue;

Calculating the Mean of a Truncated Multinormal Distribution

When I replaced

 NSolve[Mean[dist] == 82.63344, a]

With

NSolve[NExpectation[x, x \[Distributed] dist2] == 82.63344, a]

All I got was an execution that seemed to go forever (I aborted after 10 mins).

Any advice on how to solve this equation efficiently would be greatly appreciated.

$\endgroup$
1
  • 2
    $\begingroup$ FindRoot seems to work fine. FindRoot[Mean[dist] == 82.63344, {a, 1}] $\endgroup$
    – Andy Ross
    Commented Jan 9, 2013 at 23:41

1 Answer 1

4
$\begingroup$

The mean of a mixture of distributions is the mixture of their means, so simplify your life--and greatly speed up Mathematica--by precomputing the means of the mixture components separately:

d1 = Mean[UniformDistribution[{39.3, 40.5}]];
d2[a_] := Evaluate @ Mean[TruncatedDistribution[{40.5, 104}, NormalDistribution[a, 11.4]]]

A rough guess for the solution a is that it is close to the target mean. Use this as the initial value in FindRoot:

With[{target = 82.63344}, FindRoot[0.1 d1 + 0.9 d2[a] == target, {a, target}]]

$\{a\to 89.6922\}$

If you wish to check--to confirm my initial assertion about the mean of a mixture (in case I was wrong!)--go right ahead:

Mean[MixtureDistribution[{0.1, 0.9}, 
    {UniformDistribution[{39.3, 40.5}], 
    TruncatedDistribution[{40.5, 104}, NormalDistribution[a, 11.4]]}
    ] /. %]

$82.6334$

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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