No. | Degree of orientation | temperature | pressure |
---|---|---|---|
1 | 45 | 17.5 | 30 |
2 | 38 | 17.0 | 25 |
3 | 41 | 18.5 | 20 |
4 | 34 | 16.0 | 30 |
5 | 59 | 19.0 | 45 |
6 | 47 | 19.5 | 35 |
7 | 35 | 16.0 | 25 |
8 | 43 | 18.0 | 35 |
9 | 54 | 19.0 | 35 |
10 | 52 | 19.5 | 40 |
stat.py
# coding: UTF-8
import numpy as np
def stat(obj, exp):
n = exp.shape[1]
exp = np.vstack([np.ones(n), exp]) #Constant term, explanatory variable
coef = np.linalg.lstsq(exp.T, obj)[0] #Partial regression coefficient
return coef
if __name__ == '__main__':
f = (45, 38, 41, 34, 59, 47, 35, 43, 54, 52) #Degree of orientation
t = (17.5, 17.0, 18.5, 16.0, 19.0, 19.5, 16.0, 18.0, 19.0, 19.5) #temperature
p = (30, 25, 20, 30, 45, 35, 25, 35, 35, 40) #pressure
obj = np.array(f) #Objective variable
exp = np.array([t, p]) #Explanatory variable
b0, bt, bp = stat(obj, exp)
print "Multiple regression equation:Degree of orientation= %f + %f*temperature+ %f*pressure" % (b0, bt, bp)
> python stat.py
Multiple regression equation:Degree of orientation= -34.712931 + 3.469813*temperature+ 0.533009*pressure
Recommended Posts