关于IDL中多元线性回归的计算方法
IDL中提供了丰富的数学运算函数。其中部分函数同时提供了源码文件。例如今天介绍的Regress函数,可以在IDL控制台运行“.e regress.pro”查看或编辑源码。
下面介绍如何使用Regress函数进行多元线性回归计算。
已知
0.329000=a0+a1*0.673183+a2*0.428585+a3*0.328833+a4*0.238158+a5*0.193558
0.538000=a0+a1*0.666284+a2*0.425958+a3*0.326411+a4*0.236965+a5*0.193739
0.440000=a0+a1*0.730332+a2*0.494149+a3*0.390448+a4*0.294449+a5*0.244811
0.624000=a0+a1*0.642211+a2*0.384135+a3*0.289130+a4*0.200603+a5*0.161937
0.532000=a0+a1*0.704340+a2*0.495917+a3*0.402480+a4*0.327364+a5*0.282249
0.273000=a0+a1*0.651516+a2*0.411396+a3*0.315057+a4*0.225381+a5*0.181372
求:
a0、a1、a2、a3、a4、a5
解:
PRO EXAMPLE_REGRESS
x1 = [0.673183,0.428585,0.328833,0.238158,0.193558]
x2 = [0.666284,0.425958,0.326411,0.236965,0.193739]
x3 = [0.730332,0.494149,0.390448,0.294449,0.244811]
x4 = [0.642211,0.384135,0.289130,0.200603,0.161937]
x5 = [0.704340,0.495917,0.402480,0.327364,0.282249]
x6 = [0.651516,0.411396,0.315057,0.225381,0.181372]
X = [[x1],[x2],[x3],[x4],[x5],[x6]]
Y = [0.329000, 0.538000, 0.440000, 0.624000, 0.532000, 0.273000]
;初始化高斯误差
measure_errors = REPLICATE(0.5, N_ELEMENTS(Y))
;多元线性回归
result = REGRESS(X, Y, SIGMA=sigma, CONST=const, $
MEASURE_ERRORS=measure_errors)
;a1_a5即a1、a2、a3、a4、a5
a1_a5 = result
a0 = const
;验证
y1 = a0 + TOTAL(a1_a5*x1)
y2 = a0 + TOTAL(a1_a5*x2)
y3 = a0 + TOTAL(a1_a5*x3)
y4 = a0 + TOTAL(a1_a5*x4)
y5 = a0 + TOTAL(a1_a5*x5)
y6 = a0 + TOTAL(a1_a5*x6)
PRINT, '计算结果: ', y1, y2, y3, y4, y5, y6
PRINT, '已知的值: ', Y
END
结果
IDL> example_regress % Compiled module: EXAMPLE_REGRESS. 计算结果:0.328868 0.537963 0.440058 0.624062 0.532008 0.273053 已知的值:0.329000 0.538000 0.440000 0.624000 0.532000 0.273000转载:http://blog.sina.com.cn/s/blog_764b1e9d01018jtk.html
相关阅读
声明
1.本文所分享的所有需要用户下载使用的内容(包括但不限于软件、数据、图片)来自于网络或者麻辣GIS粉丝自行分享,版权归该下载资源的合法拥有者所有,如有侵权请第一时间联系本站删除。
2.下载内容仅限个人学习使用,请切勿用作商用等其他用途,否则后果自负。
a1_a5x1 少了一个和下面这类型的都少了一个乘号吧 a1_a5*x1
是的,代码被转义了。