# Problem evaluating an expression involving TransformedDistribution

Posted 9 years ago
5426 Views
|
2 Replies
|
0 Total Likes
|
 Evaluating the following expression where the LogNormal distribution has second parameter = 0.2 takes a couple of seconds on my computer:Mean[TransformedDistribution[Abs[x - 100]/Max[x, 100], x \[Distributed] LogNormalDistribution[4.6039217458887975, 0.2]]](The result is 0.141523)But when I change the second parameter to 0.5, the evaluation seems to go on indefinitely. Further, I am unable to abort the evaluation (when I choose Abort Evaluation from the Evaluation menu, nothing happens) and in order to get Mathematica to stop, I need to quit the application and restart.Mean[TransformedDistribution[Abs[x - 100]/Max[x, 100], x \[Distributed] LogNormalDistribution[4.6039217458887975, 0.5]]]Why would this be? I'm using Mathematica 8.0
2 Replies
Sort By:
Posted 9 years ago
 Thanks for the helpful reply.  Interesting that Mathematica 8 can evaluate the expression symbolically (with a & b as parameters) much faster than it can evaluate the expression numerically for a specific value of a & b.
Posted 9 years ago
 The numerical method chosen by Mathematica 8 to solve this numerical problem might not be the best one.  I am able to stop the evaluation on my machine with version 8, but the evaluation does seem to be slow. In version 9, it seems to evaluate much faster. I would suggest first trying to work the problem out symbolically like this:Mean@TransformedDistribution[Abs[x - 100]/Max[x, 100], x \[Distributed] LogNormalDistribution[a, b]]This gives the mean for generic parameters "a" and "b". You can substitute in the values or run a numerical experiment to verify the formula. The following formula takes the mean of a million sample values from the TransformedDistribution:Mean@RandomVariate[  TransformedDistribution[Abs[x - 100]/Max[x, 100],    x \[Distributed] LogNormalDistribution[4.6039217458887975, 0.5]],   1000000]