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.
FindRoot
seems to work fine.FindRoot[Mean[dist] == 82.63344, {a, 1}]
$\endgroup$