Segment 13

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

Calculation Problems

1. With <math> p = 0.3 </math> 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 <math>10^{-15}</math>?

Mean(<math> \mu </math>) = <math>(0.3 + (1- 0.3) \cdot 0))n = 0.3n</math>
Standard deviation(<math>\sigma^2</math>) = <math>(0.3 \cdot (1- \mu)^2 + (1-0.3)(0-\mu)^2)n = 0.21n</math>

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 <math> p_a + p_b + p_c + p_d = 1</math>. Since <math> p_a = 1 - (p_b + p_c + p_d) </math>, it is binomial distribution with a success of <math>p_a</math> and failure of <math> 1 - (p_b + p_c + p_d)</math>. 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)