jAER project on SourceForge

net.sf.jaer.util
Class RollingLinearRegression

java.lang.Object
  extended by net.sf.jaer.util.RollingLinearRegression

public class RollingLinearRegression
extends java.lang.Object

Does a moving or rolling linear regression (a linear fit) on updated data. The new data point replaces the oldest data point. Summary statistics holds the rollling values and are updated by subtracting the oldest point and adding the newest one. From Wikipedia article on Ordinary least squares.

Author:
tobi

Field Summary
static int LENGTH_DEFAULT
           
 
Constructor Summary
RollingLinearRegression()
          Creates a new instance of RollingLinearRegression
 
Method Summary
 void addPoint(java.awt.geom.Point2D.Float p)
          Adds a new point.
 float getIntercept()
           
 int getLength()
           
 java.util.LinkedList<java.awt.geom.Point2D.Float> getPoints()
           
 float getSlope()
           
static void main(java.lang.String[] args)
           
 void setLength(int length)
          Sets the window length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LENGTH_DEFAULT

public static final int LENGTH_DEFAULT
See Also:
Constant Field Values
Constructor Detail

RollingLinearRegression

public RollingLinearRegression()
Creates a new instance of RollingLinearRegression

Method Detail

addPoint

public void addPoint(java.awt.geom.Point2D.Float p)
Adds a new point.

Parameters:
p - the point

getLength

public int getLength()

setLength

public void setLength(int length)
Sets the window length. Clears the accumulated data.

Parameters:
length - the number of points to fit
See Also:
LENGTH_DEFAULT

getPoints

public java.util.LinkedList<java.awt.geom.Point2D.Float> getPoints()

getIntercept

public float getIntercept()

getSlope

public float getSlope()

main

public static void main(java.lang.String[] args)

jAER project on SourceForge