Package math

Class 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 the beta() method in the absence of concurrent updates returns an accurate result.

    • Constructor Summary

      Constructors 
      Constructor Description
      Regress()
      Constructs a new Regress 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 from this.
      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.
      • Methods inherited from class java.lang.Object

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

      • Regress

        public Regress()
        Constructs a new Regress instance.
    • 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 variable
        y - 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 - if regress == nullt
      • 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 from this.
      • 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