2016-11-20 4 views
0

をどのように計算します:私は私がつなぎ合わせるために管理し、次のコードを持っている平均二乗誤差に

private void CalcMSE(List<Point> data) 
{ 
    double sum = 0.0; 

     foreach (Point item in data) 
     { 
      double difference = item.m_x - item.m_y; 
      sum = sum + difference * difference; 
     } 
    double mse = sum/x; //<-- Don't know what x should be! 
    Console.WriteLine("The mean square error is {0}",mse) ; 
} 

入力は、次のとおりです。

point.m_x = 3; 
point.m_y = 1; 
pointList.Add(point); 

point.m_x = 4; 
point.m_y = 4; 
pointList.Add(point); 

point.m_x = 5; 
point.m_y = 6; 
pointList.Add(point); 

point.m_x = 6; 
point.m_y = 6; 
pointList.Add(point); 

point.m_x = 8; 
point.m_y = 10; 
pointList.Add(point); 

知ってMSEのものによるとすべきです0.77とMSR 40.89

しかし、私はxの "公式"が何であるか分かりません(コードのコメントを参照)。

線形回帰について何か知っている人は誰でも助けてくれますか?ここ

はouputsは、すべての

desired ouput

+0

何をしますと思いますか? – Kinetic

+1

data.Count()またはLenght ...または1つのカウント変数を1つ増やしてforループを増やします。 xはcountに等しくなります。 –

+0

本当ですか...? d.Count()の値は8です。 – Eminem

答えて

0

まずどうあるべきか、私はあなたが常にリストpoint = new Point(x,y)に追加する前に、新しいポイントを作成すべきだと思う、私はlist.addとは思わないですコピーを作成します。 xのよう

、私はdata.Count()は `d.Count()`について

関連する問題