private void btCount_Click(object sender, EventArgs e) { if(txtData.Text.Trim()=="") { showMsg("数据不能为空!"); return; } try { List<List<double>> X; List<double> Y; getData(out X, out Y); int i, j, m = X[0].Count, n = X.Count; txtResult.Text = ""; RegresionClass reg = new RegresionClass(X, Y); double[] P = reg.getParamters(); String s = ""; if (P != null) { for (j = 0; j < m; j++) s = s + "P[" + j.ToString() + "]=" + P[j].ToString() + "\r\n"; showResult(s); s = " 实际值, 预测值\r\n"; double TSS = 0, RSS = 0, aveY = 0; for (i = 0; i < n; i++) { double y = 0; for (j = 0; j < m; j++) y = y + P[j] * X[i][j]; s = s + format(Y[i], 2, 8) + ", " + format(y, 2, 8) + "\r\n"; aveY += Y[i]; TSS += Y[i] * Y[i];// 总平方和 RSS += (y - Y[i]) * (y - Y[i]);//回归平方和 } showResult(s); aveY = aveY / n; TSS = TSS - n * aveY * aveY; showResult("TSS=" + TSS.ToString()); showResult("RSS=" + RSS.ToString()); showResult("RR=" + (1 - RSS / TSS).ToString()); } } catch (Exception exp) { showMsg(exp.Message); } }
看不懂这一段代码,求大神解释一下
我去,谁知道这段代码是干嘛的???
我也不知道。。
http://blog.csdn.net/flowingflying/article/details/8070181
看着和这个原理挺像