Index: /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LinearLeastSquaresFitting.cs
===================================================================
--- /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LinearLeastSquaresFitting.cs	(revision 8521)
+++ /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LinearLeastSquaresFitting.cs	(revision 8522)
@@ -45,8 +45,15 @@
     public static double CalculateError(double[] dataPoints, double a1, double a0) {
       double r = 0.0;
+      double avgy = dataPoints.Average();
+      double sstot = 0.0;
+      double sserr = 0.0;
+
       for (int i = 0; i < dataPoints.Count(); i++) {
         double y = a1 * i + a0;
-        r += Math.Abs(dataPoints[i] - y);
+        sstot += Math.Pow(dataPoints[i] - avgy, 2);
+        sserr += Math.Pow(dataPoints[i] - y, 2);
       }
+
+      r = 1.0 - (sserr / sstot);
       return r;
     }
Index: /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.cs
===================================================================
--- /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.cs	(revision 8521)
+++ /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.cs	(revision 8522)
@@ -156,5 +156,5 @@
       string rowName = (string)dataRowComboBox.SelectedItem;
 
-      string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Absolut Error" };
+      string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error" };
 
       var runs = Content.Where(x => x.Results.ContainsKey(resultName));
@@ -200,4 +200,26 @@
       stringConvertibleMatrixView.Content = dt;
     }
+
+    private void addLineToChart_Click(object sender, EventArgs e) {
+      string resultName = (string)dataTableComboBox.SelectedItem;
+      string rowName = (string)dataRowComboBox.SelectedItem;
+      var runs = Content.Where(x => x.Results.ContainsKey(resultName));
+
+      foreach (Run run in runs) {
+        DataTable resTable = (DataTable)run.Results[resultName];
+        DataRow row = resTable.Rows[rowName];
+        var values = row.Values.ToArray();
+        double k, d;
+        LinearLeastSquaresFitting.Calculate(values, out k, out d);
+
+        DataRow newRow = new DataRow(row.Name + " Fitted Line");
+        for (int i = 0; i < values.Count(); i++) {
+          newRow.Values.Add(k * i + d);
+        }
+
+        if (!resTable.Rows.ContainsKey(newRow.Name))
+          resTable.Rows.Add(newRow);
+      }
+    }
   }
 }
Index: /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.designer.cs
===================================================================
--- /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.designer.cs	(revision 8521)
+++ /branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.designer.cs	(revision 8522)
@@ -50,4 +50,5 @@
       this.label1 = new System.Windows.Forms.Label();
       this.dataTableComboBox = new System.Windows.Forms.ComboBox();
+      this.addLineToChart = new System.Windows.Forms.Button();
       this.SuspendLayout();
       // 
@@ -64,5 +65,5 @@
       this.stringConvertibleMatrixView.ShowRowsAndColumnsTextBox = true;
       this.stringConvertibleMatrixView.ShowStatisticalInformation = true;
-      this.stringConvertibleMatrixView.Size = new System.Drawing.Size(492, 323);
+      this.stringConvertibleMatrixView.Size = new System.Drawing.Size(492, 294);
       this.stringConvertibleMatrixView.TabIndex = 0;
       // 
@@ -109,6 +110,18 @@
       this.dataTableComboBox.SelectedIndexChanged += new System.EventHandler(this.dataTableComboBox_SelectedIndexChanged);
       // 
+      // addLineToChart
+      // 
+      this.addLineToChart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+      this.addLineToChart.Location = new System.Drawing.Point(420, 359);
+      this.addLineToChart.Name = "addLineToChart";
+      this.addLineToChart.Size = new System.Drawing.Size(75, 23);
+      this.addLineToChart.TabIndex = 9;
+      this.addLineToChart.Text = "Fit Line";
+      this.addLineToChart.UseVisualStyleBackColor = true;
+      this.addLineToChart.Click += new System.EventHandler(this.addLineToChart_Click);
+      // 
       // RunCollectionStatisticalTabularView
       // 
+      this.Controls.Add(this.addLineToChart);
       this.Controls.Add(this.dataRowComboBox);
       this.Controls.Add(this.label2);
@@ -129,4 +142,5 @@
     private System.Windows.Forms.Label label1;
     private System.Windows.Forms.ComboBox dataTableComboBox;
+    private System.Windows.Forms.Button addLineToChart;
   }
 }
