Class XYStats

java.lang.Object
uk.ac.starlink.ttools.plot.XYStats

public class XYStats extends 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

    Modifier and Type
    Method
    Description
    void
    addPoint(double x, double y)
    Submits a data point for calculations.
    double
    Returns the product moment correlation coefficient.
    double[]
    Returns the polynomial coefficients of a linear regression line for the submitted data.
    double[]
    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 Details

    • 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 Details

    • 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