title: How to find best fit line using Principal Component Analysis?
body: <p>I'm plotting graphs in windows application in C#.
  I've used 
  <a href="http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html" rel="nofollow">Least Squares Fitting--Perpendicular Offsets</a>
  to find best fit line. But my data source varies from vertical line to (almost) horizontal one.</p>
  
  <p>Then I read about PCA, and Accord.net libraries. I've written some code, but not getting what exactly to do further.</p>
  
  <p><strong>I have a list of DataPoints of a graph.</strong></p>
  
  <pre><code>DataTable dt = new DataTable();
  dt.Columns.Add("X", typeof(double));
  dt.Columns.Add("Y", typeof(double));
  
  foreach (DataPoint dp in listOfPoints)
  {
      DataRow dr = dt.NewRow();
      dr["X"] = dp.XValue; 
      dr["Y"] = dp.YValues[0];
      dt.Rows.Add(dr);
  }
  
  string[] columnNames;
  double[,] sourceMatrix = dt.ToMatrix(out columnNames);
  DescriptiveAnalysis sda = new DescriptiveAnalysis(sourceMatrix, columnNames);
  sda.Compute();
  AnalysisMethod method = AnalysisMethod.Center;
  
  PrincipalComponentAnalysis pca = new PrincipalComponentAnalysis(sda.Source, method);
  pca.Compute();
  double[] mean = sourceMatrix.Mean();
  double[,] eigenVectors = pca.ComponentMatrix;
  </code></pre>
  
  <p>After getting eigen vectors how to utilize them in plotting best fit line.</p>