Chapter 4 : Information Analysis

Example 4.2 Page No : 4-22

In [1]:
from numpy import *

#initialisation of variables
y_bar = 19.5	#in
x = 396.8	#in
n = 6	#in
y1 = 2.20	#in
x1 = 51.14	#in
p = 5.64	#in
ob_y = array([44,20,24,14,12,3])
ob_x = array([5.3,3.5,3.,1.2,0.48,-0.26])

#CALCULATIONS
Beta = round((x-n*(y_bar)*(y1))/(x1-n*(y1)**2),2)
y = around(y_bar + Beta*(ob_x - 2.2),decimals=1)
Ri = ob_y - y
sumRi = sum(Ri)

#RESULTS
print "Beta B = %.2f"%Beta
print "residuals Ri are : " ,Ri
print 'the method of leate squares  = %.2f minimum'%(sumRi)

# note : answer is slighty different because of rounding off error.
Beta B = 6.31
residuals Ri are :  [ 4.9 -7.7 -0.5  0.8  3.4 -1. ]
the method of leate squares  = -0.10 minimum

Example 4.3 Page No : 4-30

In [18]:
from numpy import *

#initialisation of variables
a = 12.	    #in
h = 121.	#in
p = 11.     #in
s = 220.	#in
observed_time = array([11,12,13,14,15,16,17,18,19,20,21])
i = array([1,2,3,4,5,6,7,8,9,10,11])
observed_magnitude = array([2,4,6,8,10,12,14,16,18,20,22])
y_uy = array([-10,-8,-6,-4,-2,0,2,4,6,8,10])

#CALCULATIONS
B = a/p*(h-1)*s	#per unit
n = len(i)
i_6 = i - (n+1)/2
i_6_y_uy = (i - (n+1)/2)*y_uy

#RESULTS
print "Observed Time            ", observed_time
print "Order,i                  ", i
print "[i-(n+1)/2]              ", i_6
print "Observed magnitude       ", observed_magnitude
print "Deviation from mean      ", y_uy
print "[i-(n+1)/2](y-uy)        ", i_6_y_uy 
Observed Time             [11 12 13 14 15 16 17 18 19 20 21]
Order,i                   [ 1  2  3  4  5  6  7  8  9 10 11]
[i-(n+1)/2]               [-5 -4 -3 -2 -1  0  1  2  3  4  5]
Observed magnitude        [ 2  4  6  8 10 12 14 16 18 20 22]
Deviation from mean       [-10  -8  -6  -4  -2   0   2   4   6   8  10]
[i-(n+1)/2](y-uy)         [50 32 18  8  2  0  2  8 18 32 50]

Example 4.5 Page No : 4-31

In [1]:
import math 
	
#initialisation of variables
a = 4404.	#ft
q = 9.	#ft
mu = 12.	#ft
	
#CALCULATIONS
F = math.sqrt(a/q)	#ft
CF = F/mu*100	#percent
	
#RESULTS
print 'the coefficient of fluctuation is  = %.0f percent'%(CF)
the coefficient of fluctuation is  = 184 percent

Example 4.7 Page No : 4-35

In [2]:
import math 
	
#initialisation of variables
h2 = 5	#in
x = 3.72	#in
x1 = 1.28	#in
	
#CALCULATIONS
H = h2*x1/x	#in
	
#RESULTS
print 'the either side of the center of the scale = %.2f in'%(H)
the either side of the center of the scale = 1.72 in

Example 4.8 Page No : 4-35

In [3]:
	
#initialisation of variables
p = 80	#in
q = 20	#in
	
#CALCULATIONS
K = p+q	#ft
	
#RESULTS
print 'the moments of the arithmetically normal frequency curve = %.0f ft'%(K)
the moments of the arithmetically normal frequency curve = 100 ft

Example 4.9 Page No : 4-38

In [4]:
import math 
	
#initialisation of variables
g = 3.2541	#in
g1 = 3.46	#in
m = 0.5390	#ft
h = 2./99	#ft
p = 1.52	#ft
	
#CALCULATIONS
L = math.sqrt(g*h)	#in
mu = g1*p	#in
M = g1/p	#percent
	
#RESULTS
print 'the points necessary to plot the straigt line of fit on math.log probability = %.2f percent'%(M)
the points necessary to plot the straigt line of fit on math.log probability = 2.28 percent