
## this is com41a of august 2024,
#  the little thing for Nils-Emil Ex 1.2(c)
#  X = "2 with noise" + "2 with noise" is N(4,2\sigma^2)
#  4 + sqrt(2)\sigma Z is outside [-3.5, 4.5]
#  when |Z| > 0.5/(sqrt(2)\sigma)

pp <- function(sigma)
{
1 - ( pnorm(0.5/(sqrt(2)*sigma)) - pnorm(-0.5/(sqrt(2)*sigma)) )
}

curve(pp,0,20,xlab="sigma",ylab="prob that 2 + 2 is not 4")

## aha, rather slow convergence to 1, for growing sigma 

## when is pp(sigma) = 0.50, by the way?
Q <- function(sigma)
{ (pp(sigma)-0.5)^2 }

well <- nlm(Q,1)
sigma0 <- well$estimate
print( round(c(sigma0,pp(sigma0)),4) )
# 0.5242 0.5000 
