# Chapter 6: Sampling Distributions¶

## Example, page-182¶

In [1]:
# Variable declaration
n = 10                                            # Sample size
N = 1000                                          # population size

# Calculation
from scipy import *
from pylab import *

# as we know correction factor = (N-n)/(N-1)
corr_fact = (float(N-n))/(N-1)                    # correction factor
corr_fact = round(corr_fact,3)

# Result
print "Correction Factor: ",corr_fact

Correction Factor:  0.991


## Example, page-185¶

In [2]:
# Variable declaration
Mean = 513.3           # Mean( in square feet)
std_dev = 31.5         # Standard deviation ( in square feet)
n = 40                 # Number of cans
x1 = 510.0             # lower limit of area (in square feet)
x2 = 520.0             # upper limit of area (in square feet)

# Calculation
from scipy import *
from pylab import *

# as we know      Z = (X-Mean) / (std_dev/sqrt(n))
Z1 = round( ((x1-Mean) / (std_dev/sqrt(n))),3)          # Z value corresponding to lower limit
Z2 = round( ((x2-Mean) / (std_dev/sqrt(n))),3)          # Z value corresponding to upper limit

# Using values of Z1 & Z2 from Table-3
P = 0.6553        # Requires probability (from Table-3)

# Result
print "required probability: ",P

required probability:  0.6553


## Example, page-188¶

In [3]:
# Variable declaration
Mean = 12.40           # Mean( in minutes)
std_dev = 2.48         # Standard deviation ( in minutes)
n = 20                 # sample size
x = 10.63              # observes time( in minutes)

# Calculation
from scipy import *
from pylab import *

t = (x-Mean) / (std_dev/sqrt(n))        # t-value corresponding to observation
t = round( t,2)
v = n-1                                 # degree of freedom

# corresponding to v = 19 , porbability that t will be below -2.861, is 0.005 (Table-4)
# As 0.005 is very small probability, so data tend to refute manufacturer's claim

# Result
print " The Data tend to refute manufacturer's claim"

 The Data tend to refute manufacturer's claim


## Example, page-190¶

In [4]:
# Variable declaration
n = 20           # sample size
var_pop = 0.000126           # variance of population
var_samp = 0.0002            # variance of sample

# Calculation
from scipy import *
from pylab import *

chi_square = ((n-1)*var_samp) / var_pop           # chi square value
chi_square = round(chi_square , 1)                # i.e. 30.2

# From Table-5 for v = 19 and alpha = 0.05, chi_square(thoeritical) = 30.1, thus probability will be less than 0.05

# Result
print "chi square value: ",chi_square
print "probability of rejection of shipment is less than 0.05"

chi square value:  30.2
probability of rejection of shipment is less than 0.05


## Example, page-190¶

In [5]:
# Variable declaration
n1 = 7                  # Smaple-1 size
n2 = 13                 # Smaple-2 size

# Calculation
from scipy import *
from pylab import *

# Using Table-6, for v1 = 6 and v2 = 12 ,F(0.05) = 3.00  thus probability is 0.05
P = 0.05                # required probability

# Result
print "required probability: ",P

required probability:  0.05


## Example, page-191¶

In [6]:
# Variable declaration
v1 = 10        # Degree of freedom a corresponding to (a,b)
v2 = 20        # Degree of freedom b corresponding to (a,b)

# Calculation
from scipy import *
from pylab import *

# we need to find f(0.95) at (10,20) i.e. 1/ f(0.05) at(20,10)
f = 1 / 2.77            # Required value  f(0.05) at(20,10) = 2.77 from Table-6
f = round(f,2)

# Result
print "F value: ",f

F value:  0.36