# Segment 13

## Calculation Problems

1. With $p = 0.3$ and value of n how big is the largest discrepancy between the Binomial probability pdf and the approximating Normal pdf? What value of n does the value become smaller than $10^{-15}$?

Mean($\mu$) = $(0.3 + (1- 0.3) \cdot 0))n = 0.3n$
Standard deviation($\sigma^2$) = $(0.3 \cdot (1- \mu)^2 + (1-0.3)(0-\mu)^2)n = 0.21n$

import numpy as np
from scipy.stats import binom
from scipy.stats import norm

def dis(n, p = 0.3):
mean = n*0.3
var = n*0.21
std = var**0.5
arr = [i for i in range(1, n+1)]
binomial = binom.pmf(arr, n,p)
normal = norm.pdf(arr, scale = std, loc= mean)

return normal-binomial


2. Show that four random variable are multinomially distributed, each is binomially distributed

If the four variables are multinomial then $p_a + p_b + p_c + p_d = 1$. Since $p_a = 1 - (p_b + p_c + p_d)$, it is binomial distribution with a success of $p_a$ and failure of $1 - (p_b + p_c + p_d)$. Similar arguments can be made for the other three random variables.

## Class Activity

from scipy.stats import t
from scipy.stats import norm
from scipy.stats import expon
from scipy.stats import f
from scipy.stats import binom

#Normal, p<5%, 2 sided
print norm.ppf(0.025)
print norm.ppf(1-0.025)

#Student, nu=4, p<5%, 2-sided
print t.ppf(0.025,4)
print t.ppf(1-0.025, 4)

#Studnt, n=2, p<1%, 1-sided
print t.ppf(1-0.01, 2)

#Exponential, mu=2.7, p<0.001, 1-sided
print expon.ppf(1-0.001,scale=2.7)

#Exponential, mu=2.7, p<0.0001, 2-sided
print expon.ppf(1-0.0005,scale=2.7)
print expon.ppf(0.0005, scale=2.7)

#F-distribution, nu1=6, nu2=8, p<0.1%, 1-sided
print f.ppf(1-0.001,6,8)