X tosses biased coin with probability p and y tosses non biased coin
Answers
Answer:
Step-by-step explanation:
prints a table of relevant results for nearby values of n, and makes bar charts of the two binomial distributions to illustrate the overlap.
p = .3; q = .7
n = 1:10000; c = n*(q + p)/2
cond = (pbinom(c, n, p) >= .95 & pbinom(c, n, q) <= .05)
n.min = min(n[cond]); n.min
## 17
cbind(n, c, pbinom(c,n,p), pbinom(c, n, q), cond)[(n.min-2):(n.min+7),]
n c cond
## 15 7.5 0.9499875 0.05001254 0
## 16 8.0 0.9743265 0.07435155 0
## 17 8.5 0.9597231 0.04027694 1
## 18 9.0 0.9790320 0.05958588 0
## 19 9.5 0.9674466 0.03255336 1
## 20 10.0 0.9828552 0.04796190 1
## 21 10.5 0.9736101 0.02638994 1
## 22 11.0 0.9859649 0.03874479 1
## 23 11.5 0.9785520 0.02144800 1
## 24 12.0 0.9884977 0.03139365 1
x = 0:n.min; pdfp = dbinom(x, n.min, p); pdfq = dbinom(x,n.min,q)
mlb = paste("BINOM(",n.min,", ",p,") and BINOM(",n.min,", ",q,")", sep="")
plot(x-.1, pdfp, type="h", ylab="PDF", xlab="Successes",
ylim=c(0, max(pdfp,pdfq)), col="red", main=mlb)
lines(x+.1, pdfq, type="h", col="blue")
abline(v=c[n.min], lty="dotted"); abline(h=0, col="green2")