Class XYStats
java.lang.Object
uk.ac.starlink.ttools.plot.XYStats
Calculates X-Y correlation statistics.
- Since:
- 15 Jul 2004
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsConstructorDescriptionXYStats(boolean xLog, boolean yLog) Constructs a new correlation statistics calculator. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPoint(double x, double y) Submits a data point for calculations.doubleReturns 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.
-
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 scaleyLog- 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 coordinatey- 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
-