from Numeric import *
from RandomArray import *
from LinearAlgebra import *

ncols=4
sum1=[0,0,0,0]
sum2=[0,0,0,0]
nsum=[0,0,0,0]
i=0
while i<100:
    r1=array([normal(563,23),normal(1275,24),normal(732,45),normal(1283,19)])
    r2=array([normal(3425,93),normal(834,37),normal(2953,62),normal(843,32)])
    r3=array([normal(9432,63),normal(853,93),normal(8410,93),normal(4932,56)])
    r4=array([normal(485,45),normal(1274,34),normal(3842,25),normal(682,23)])
    a=array([r1,r2,r3,r4])
    b=array([[normal(25,3)],[normal(-52,18)],[normal(92,6)],[normal(-10,0.4)]])
    c=solve_linear_equations(a,b)
    for j in range(ncols):
        sum1[j]=sum1[j]+c[j]
        sum2[j]=sum2[j]+c[j]*c[j]
        nsum[j]=nsum[j]+1
        i=i+1

for j in range(ncols):
    print "Value= ",j
    print "avg= ",sum1[j]/nsum[j]
    print "stdev= ",sqrt((sum2[j]/nsum[j])-(sum1[j]/nsum[j])**2)