yesterday i started to mess around with this book :

*Bayesian computation with R*and i stopped at the first chapter (on exercises) . in this exercise i have to estimate the true probability of coverage (P(p ele. C(y)) where C is the confidence). so what i have to do is to simulate for sample size n=20 and p = 0.5 using the

**rbinom**function, the value y. then write a function to calculate binomial confidence interval

Code:

```
bin.conf = function (y,n){
z = qnorm(0.95);
phat = y/n;
se = sqrt(phat*(1-phat)/n);
return(c(phat-z*se,phat+z*se))
}
```

so the problem is how do i do that ?

first i iterate :

Code:

```
for (i in 1:20){
y = rbinom(1,0.5,20);
bin = bin.conf(y,20);
# and now what how do i estimate the true probability of coverage
}
```

so if anyone has some spare time to help me i would appreciate it ! thank you

baxy