#C6.txt:Binomial distributions Help:=proc(): print(` Bp(n,p,k), HT(n,p,x) , dbeta(p,a,b)`): end: #Bp(n,p,k): The prob. mass function of the Binomial distribution, tossing a coin n times #Pr(H)=p, k=0..n, Pr(X=k) Bp:=proc(n,p,k) binomial(n,k)*p^k*(1-p)^(n-k): end: #HT(n,p,x): Frequentist Hypothesis testing. If the owner of the coin claims that Pr(H) is at least #p what is the cutoff of number of Heads below which you can be confident with level of confidence #x that he is a lier. HT:=proc(n,p,x) local k1,k,su: for k from 0 to n while add(Bp(n,p,k1),k1=0..k)<=1-x do od: k-1: end: dbeta:=proc(p,a,b): GAMMA(a+b)/(GAMMA(a)*GAMMA(b))*p^(a-1)*(1-p)^(b-1):end: #Post~Likelihood*Prior ~ p^k*(1-p)^(n-k)*dbeta(a,b)=p^k*(1-p)^(n-k)*p^(a-1)*(1-p)^(b-1)= #p^(k+a-1,n-k+b-1)= dbeta(k+a,n-k+b)