'Normal distribution `N(mu, 1)>1.96`
I try to write an R code to find value of mu s.t. the Normal distribution satisfies the probability P(N(mu, 1)>1.96)=0.95 (i.e., P(Z>1.96)=0.95 where Z~N(mu, 1) and mu is what I want to get). Is there any code for solving the parameter of distribution? It seems that this will be a integral equation about mu such that
int_{1.96}^{\infty} 1/\sqrt{2\pi} \exp(-(x-mu)^2/2)dx=0.95
We can sample Normal distribution from dnorm(x, mean, sd) or
rnorm(n, mean, sd). But we need to first take value for mean and sd.
Solution 1:[1]
Here are some other options
- Using
qnorm+uniroot(similar to the answer by @Rui Barradas)
> uniroot(function(m) qnorm(0.05, m) - 1.96, c(-1e3, 1e3))$root
[1] 3.604854
- Using
erfinvfrompracmapackage
library(pracma)
> 1.96 + sqrt(2) * pracma::erfinv(2 * 0.95-1)
[1] 3.604854
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ThomasIsCoding |
