This calculation takes a very long time!
- Why?
- 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]
dist = NormalDistribution[μ, 3/10];
The integral is
n[μ_] = Integrate[PDF[dist, x], {x, -∞, 50113/100}]
(* 1/2 Erfc[(-50113 + 100 μ)/(30 Sqrt[2])] *)
Alternatively, it is just the CDF
n2[μ_] = CDF[dist, 50113/100]
(* 1/2 Erfc[5/3 Sqrt[2] (-(50113/100) + μ)] *)
Verifying that they are equivalent expressions,
n[μ] == n2[μ] // Simplify
(* True *)
The exact solution is
sol = Solve[n[μ] == 1/20, μ][[1]] // Quiet
(* {μ -> 1/100 (50113 + 30 Sqrt[2] InverseErfc[1/10])} *)
Verifying the solution,
n[μ] /. sol
(* 1/20 *)
The numeric value is
sol // N
(* {μ -> 501.623} *)
Solve[]
here, it is better to use the intended functions Quantile[]
or InverseCDF[]
.
$\endgroup$
Commented
Oct 10, 2018 at 2:13
Solve
or Reduce
would still be needed, e.g., Solve[Quantile[dist, 1/20] == 50113/100, μ][[1]]
or Solve[InverseCDF[dist, 1/20] == 50113/100, μ][[1]]
$\endgroup$
Commented
Oct 10, 2018 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.
.3
and501.13
withRationalize[0.3]
andRationalize[ 501.13]
$\endgroup$Solve[Integrate[5/3 E^(-(50/9) (x - μ)^2) Sqrt[2/π], {x, -∞, 50113/100}] == 5/100, μ][[1]] // AbsoluteTiming (* {2.81637, {μ -> 1/100 (50113 + 30 Sqrt[2] InverseErfc[1/10])}*)
$\endgroup$