Class SimpleLinearRegression

  • All Implemented Interfaces:
    Minimizer.Func

    public class SimpleLinearRegression
    extends java.lang.Object
    implements Minimizer.Func

    This class will do a linear regression by minimizing the squared error between the points provided to the constructor and the line specified by y = m[0]x + m[1]

    NOTE: The error term is calculated using the vertical distance. That is it minimizes the error in the 'y' term only. This is more robust for determining the slope/intercept form of a line because the starting point cannot be rotated through the Y axis. In other words, if the slope of the points is approximately -3.0 and the slope of the starting iteration is 3.0, then RAISING the slope lowers the perpendicular distance. This moves the iterations in the wrong direction.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      double[] x  
      double[] y  
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleLinearRegression​(double[] x, double[] y)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double func​(double[] lineDefMb)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • y

        public final double[] y
      • x

        public final double[] x
    • Constructor Detail

      • SimpleLinearRegression

        public SimpleLinearRegression​(double[] x,
                                      double[] y)
    • Method Detail

      • func

        public double func​(double[] lineDefMb)
        Specified by:
        func in interface Minimizer.Func