2
$\begingroup$

I have 2 random independent variables x and y. x is the strength of a bar and y is the force applied to the bar. x has a Lognormal distribution with mean 10. and standard deviation 2. y has a Normal distribution with mean 5. and standard deviation 2. The bar will fail if we have x-y = 0. How to calculate the probability of the bar to fail? I tried the following and expected that probability of fail would be 0.032.

NProbability[
 x - y == 0.,
 {
  x \[Distributed] LogNormalDistribution[10., 2.],
  y \[Distributed] NormalDistribution[5., 2.]
  },
 Method -> {"MonteCarlo"}
 ]
$\endgroup$
  • 3
    $\begingroup$ I think your condition should be y > x (or equivalently x - y < 0). That is, the bar will fail when the applied force is greater. Your current statement is that the bar will fail when the applied force is exactly equal to its strength, which for smooth distributions will happen with probability zero. $\endgroup$ – 2012rcampion Sep 12 '15 at 23:20
8
$\begingroup$

You have two related problems. The first is that NProbability finds the probability of a condition being met. However, your condition x - y == 0 is only true when x and y are exactly equal, which happens with probability zero.

Fixing the condition to y > x (and using the default Method), we get a probability of:

NProbability[
 y > x,
 {
  x \[Distributed] LogNormalDistribution[10, 2], 
  y \[Distributed] NormalDistribution[5, 2]
 },
 AccuracyGoal -> 30
]

(* 0. *)

Practically zero, much lower than you expect. I think you have a second problem, which is that LogNormalDistribution does not do what you expect it to. It is the distribution of Exp[x], where x is normally distributed with the parameters given to LogNormalDistribution. Therefore in general the mean and standard deviation of the distribution will not be the numbers you put in.

We can use Solve to find out what the parameters should be:

soln = NSolve[Through[{Mean, StandardDeviation}[LogNormalDistribution[a, b]]] == {10, 2}
 && b > 0, {a, b}, Reals]

(* {{a -> 2.28297, b -> 0.198042}} *)

Now we can use NProbability again (without any special options):

NProbability[y > x, {
 x \[Distributed] LogNormalDistribution[a, b] /. First@soln,
 y \[Distributed] NormalDistribution[5, 2]
}]

(* 0.0321748 *)

And this time we get exactly what you expect.

$\endgroup$
  • $\begingroup$ I had overlooked the point regarding the mean and standard deviation the first time I read the OP's question. I'm glad you expanded your comment into a full answer: that's an excellent explanation; I hope the OP will appreciate it as well. $\endgroup$ – MarcoB Sep 13 '15 at 0:25

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.