Package math
Class Regress
- java.lang.Object
-
- math.Regress
-
public class Regress extends java.lang.Object
Class
Regress
estimates a regression coefficient.Instances of class
Regress
are not thread-safe, but concurrent updates are permitted, and invocation of thebeta()
method in the absence of concurrent updates returns an accurate result.
-
-
Constructor Summary
Constructors Constructor Description Regress()
Constructs a newRegress
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(double x, double y)
Records the specified values of the dependent and independent variables.void
add(Regress regress)
Records the specified values of the dependent and independent variables.double
beta()
Returns the regression coefficient for the recorded values of the independent and dependent variables.long
cnt()
Returns the number of recorded values of the independent variable.void
reset()
Deletes all recorded values fromthis
.double
sumX()
Returns the sum of recorded values of the independent variable.double
sumXX()
Returns the sum of the squared recorded values of the independent variable.double
sumXY()
Returns the sum of the products of the recorded values of the independent and dependent variables.double
sumY()
Returns the sum of recorded values of the dependent variable.
-
-
-
Method Detail
-
add
public void add(double x, double y)
Records the specified values of the dependent and independent variables.- Parameters:
x
- the value of the independent variabley
- the value of the dependent variable
-
add
public void add(Regress regress)
Records the specified values of the dependent and independent variables.- Parameters:
regress
- recorded values of the independent and dependent variables- Throws:
java.lang.NullPointerException
- ifregress == null
t
-
cnt
public long cnt()
Returns the number of recorded values of the independent variable. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the number of recorded values of the independent variable
-
sumX
public double sumX()
Returns the sum of recorded values of the independent variable. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the sum of recorded values of the independent variable
-
sumY
public double sumY()
Returns the sum of recorded values of the dependent variable. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the sum of recorded values of the dependent variable
-
sumXX
public double sumXX()
Returns the sum of the squared recorded values of the independent variable. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the sum of the squared recorded values of the independent variable
-
sumXY
public double sumXY()
Returns the sum of the products of the recorded values of the independent and dependent variables. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the sum of the products of the recorded values of the independent and dependent variables
-
reset
public void reset()
Deletes all recorded values fromthis
.
-
beta
public double beta()
Returns the regression coefficient for the recorded values of the independent and dependent variables. The returned value is NOT an atomic snapshot. An accurate result is guaranteed only if no concurrent updates occur during method invocation.- Returns:
- the regression coefficient for the recorded values of the independent and dependent variables
-
-