Result




=================================================================================
Code
=================================================================================
12.2
——————————————————————————————-
#!/usr/bin/env python2.7
x=[]
y=[]
file=’12.2.csv’
import csv
with open(file,’rb’) as cf:
reader=csv.reader(cf)
for row in reader:
xy=row
x.append(int(xy[0]))
y.append(int(xy[1]))
print ‘Read from’,file
print ‘x=’,x
print ‘y=’,y
import scipy.stats as s
slope,intercept,rvalue,pvalue,stderr=s.linregress(x,y)
print
print ‘—-lineregress———-‘
print
print ‘Y =’,slope,’* X +’,intercept
print
print ‘————————-‘
print
print ‘== Produced by Jiajian Wu ==’
————————————————————————————-
12.4
————————————————————————————–
#!/usr/bin/env python2.7
x=[]
y=[]
file=’12.4.csv’
import csv
with open(file,’rb’) as cf:
reader=csv.reader(cf)
for row in reader:
xy=row
x.append(int(xy[0]))
y.append(int(xy[1]))
print ‘Read from’,file
print ‘x=’,x
print ‘y=’,y
import scipy.stats as s
slope,intercept,rvalue,pvalue,stderr=s.linregress(x,y)
print
print ‘—-lineregress———-‘
print
print ‘Y =’,slope,’* X +’,intercept
print
print ‘————————-‘
print
print ‘== Produced by Jiajian Wu ==’
————————————————————————————-
12.6
————————————————————————————–
#!/usr/bin/env python2.7
x=[]
y=[]
file=’12.6.csv’
import csv
with open(file,’rb’) as cf:
reader=csv.reader(cf)
for row in reader:
xy=row
x.append(int(xy[0]))
y.append(int(xy[1]))
print ‘Read from’,file
print ‘x=’,x
print ‘y=’,y
import scipy.stats as s
slope,intercept,rvalue,pvalue,stderr=s.linregress(x,y)
print
print ‘—-lineregress———-‘
print
print ‘Y =’,slope,’* X +’,intercept
print
print ‘————————-‘
print
print ‘== Produced by Jiajian Wu ==’
————————————————————————————-
12.8
————————————————————————————–
#!/usr/bin/env python2.7
x=[]
y=[]
file=’12.8.csv’
import csv
with open(file,’rb’) as cf:
reader=csv.reader(cf)
for row in reader:
xy=row
x.append(float(xy[0]))
y.append(float(xy[1]))
print ‘Read from’,file
print ‘x=’,x
print ‘y=’,y
import scipy.stats as s
slope,intercept,rvalue,pvalue,stderr=s.linregress(x,y)
print
print ‘—-lineregress———-‘
print
print ‘Y =’,slope,’* X’,intercept
print
print ‘————————-‘
print
print ‘== Produced by Jiajian Wu ==’
=============================================================
CSV
=============================================================
12.2
—————————————————————————–
158,349
296,510
87,301
110,322
436,550
—————————————————————————–
12.4
—————————————————————————–
1425,277
273,100
915,120
1687,259
234,40
142,25
259,57
258,31
894,141
—————————————————————————
12.6
—————————————————————————
12,17
21,15
28,22
8,19
20,24
—————————————————————————
12.8
—————————————————————————
12.5,148
3.7,55
21.6,338
60,994
37.6,541
6.1,89
16.8,126
41.2,379