Class XYStats


  • public class XYStats
    extends java.lang.Object
    Calculates X-Y correlation statistics.
    Since:
    15 Jul 2004
    Author:
    Mark Taylor (Starlink)
    • Constructor Summary

      Constructors 
      Constructor Description
      XYStats​(boolean xLog, boolean yLog)
      Constructs a new correlation statistics calculator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPoint​(double x, double y)
      Submits a data point for calculations.
      double getCorrelation()
      Returns the product moment correlation coefficient.
      double[] getLinearCoefficients()
      Returns the polynomial coefficients of a linear regression line for the submitted data.
      double[] linearRegressionLine()
      Calculates the linear regression line for the submitted points.
      • Methods inherited from class java.lang.Object

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

      • XYStats

        public XYStats​(boolean xLog,
                       boolean yLog)
        Constructs a new correlation statistics calculator.
        Parameters:
        xLog - whether the X coordinates are being plotted on a logarithmic scale
        yLog - whether the Y coordinates are being plotted on a logarithmic scale
    • Method Detail

      • addPoint

        public void addPoint​(double x,
                             double y)
        Submits a data point for calculations.
        Parameters:
        x - X coordinate
        y - Y coordinate
      • getLinearCoefficients

        public double[] getLinearCoefficients()
        Returns the polynomial coefficients of a linear regression line for the submitted data.
        Returns:
        2-element array: (intercept, gradient)
      • getCorrelation

        public double getCorrelation()
        Returns the product moment correlation coefficient.
        Returns:
        correlation coefficient
      • linearRegressionLine

        public double[] linearRegressionLine()
        Calculates the linear regression line for the submitted points. The endpoints of the line correspond to the lowest and highest X values submitted.
        Returns:
        4-element array giving the endpoints (low-X, low-Y, high-X, high-Y) of a linear regression line for these data