Premium problem110. Threshold for the Top q Fraction

Medium Locked

For X∼N(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2), return the threshold above which exactly a q fraction of the distribution lies. This is the cut-off an anomaly detector would use for a target alert rate.

You need the inverse normal CDF. There is no closed form, so bisect on the standard normal: find z with Φ(z)=1−q\Phi(z) = 1 - q, then return μ+zσ\mu + z\sigma.

Input

mu = 0.0
sigma = 1.0
q = 0.05

Output

1.6448536269514715

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)