How to speed up this calculation regarding the normal distribution?

This calculation takes a very long time!

1. Why?
2. How can I improve it?

Thanks!

n[μ_] := Integrate[1/(0.3 Sqrt[2 π]) E^(-(1/2) ((x - μ)/0.3)^2), {x, -∞, 501.13}]

Solve[n[μ] == 0.05]
• try replacing .3 and 501.13 with Rationalize[0.3] and Rationalize[ 501.13] – kglr Oct 9 '18 at 21:24
• Works quite fast:Solve[Integrate[5/3 E^(-(50/9) (x - μ)^2) Sqrt[2/π], {x, -∞, 50113/100}] == 5/100, μ][] // AbsoluteTiming (* {2.81637, {μ -> 1/100 (50113 + 30 Sqrt InverseErfc[1/10])}*) – Mariusz Iwaniuk Oct 9 '18 at 21:38
• Pretty sure this is a dupe... – J. M. will be back soon Oct 10 '18 at 2:14
• @kglr Interesting! Why does Rationalize work? – GambitSquared Oct 10 '18 at 5:44

dist = NormalDistribution[μ, 3/10];

The integral is

n[μ_] = Integrate[PDF[dist, x], {x, -∞, 50113/100}]

(* 1/2 Erfc[(-50113 + 100 μ)/(30 Sqrt)] *)

Alternatively, it is just the CDF

n2[μ_] = CDF[dist, 50113/100]

(* 1/2 Erfc[5/3 Sqrt (-(50113/100) + μ)] *)

Verifying that they are equivalent expressions,

n[μ] == n2[μ] // Simplify

(* True *)

The exact solution is

sol = Solve[n[μ] == 1/20, μ][] // Quiet

(* {μ -> 1/100 (50113 + 30 Sqrt InverseErfc[1/10])} *)

Verifying the solution,

n[μ] /. sol

(* 1/20 *)

The numeric value is

sol // N

(* {μ -> 501.623} *)
• Instead of using Solve[] here, it is better to use the intended functions Quantile[] or InverseCDF[]. – J. M. will be back soon Oct 10 '18 at 2:13
• @J.M.issomewhatokay. - seems like Solve or Reduce would still be needed, e.g., Solve[Quantile[dist, 1/20] == 50113/100, μ][] or Solve[InverseCDF[dist, 1/20] == 50113/100, μ][] – Bob Hanlon Oct 10 '18 at 2:43

We have the identity

CDF[NormalDistribution[μ, σ], x] == CDF[NormalDistribution[], (x - μ)/σ] // Simplify
True

which means

With[{σ = 3/10, p = 1/20, x = 50113/100},
x - σ Quantile[NormalDistribution[], p]] // N

is the solution to the problem posed in the OP.

• (I only have a smartphone and gedanken Mathematica right now, so please edit my answer if the formatting looks off.) – J. M. will be back soon Oct 10 '18 at 3:51
• "I only have a smartphone and gedanken Mathematica right now"...Now that's what I call confidence and a good memory. (And no surprise, it checks out.) – JimB Oct 10 '18 at 5:59
• It ain't a great situation, but I'm making the most of what I have. :) – J. M. will be back soon Oct 10 '18 at 6:44