papaya
Class Linear

java.lang.Object
  extended by papaya.Linear
All Implemented Interfaces:
PapayaConstants

public class Linear
extends Object
implements PapayaConstants

Contains methods related to determining the linear linear relationship between two datasets (of equal arrays) such as the best-fit linear line parameters, box-cox transformations, etc.


Nested Class Summary
static class Linear.BoxCox
          Contains methods related to the Box-Cox transformation of a data set; useful in determining the best transformation that will yield the best method for converting a monotonic, non-linear relationship between x and y into a linear one.
static class Linear.Significance
          Contains methods used to compute the significance, or pvalue of the input correlations.
static class Linear.StdErr
          Contains methods related to computing the standard errors of the residuals, slope and intercept associated with the best-fit linear line.
 
Field Summary
 
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
 
Constructor Summary
Linear()
           
 
Method Summary
static float[] bestFit(float[] x, float[] y)
          Returns the slope and y-intercept of the best fit linear line z = slope*x + intercept by minimizing the sum of least squares between z and the y.
static float bestFit(float[] x, float[] y, float intercept)
          Returns the slope of the best fit linear line for the prescribed y-intercept.
static float[] residuals(float[] x, float[] y)
          Compute and return the array of residuals given by Delta_i = z_i - y_i, where z_i = (slope*x_i + intercept) is the best fit linear line.
static float[] residuals(float[] x, float[] y, float slope, float intercept)
          Compute and return the array of residuals given by Delta_i = z_i - y_i, where z_i = (slope*x_i + intercept) is the best fit linear line.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Linear

public Linear()
Method Detail

bestFit

public static float[] bestFit(float[] x,
                              float[] y)
Returns the slope and y-intercept of the best fit linear line z = slope*x + intercept by minimizing the sum of least squares between z and the y.

Parameters:
x - the x data
y - the y data
Returns:
a 2-by-1 array with the first element coeff[0]corresponding to the slope, and the second element coeff[1] equal to the y-intercept.

bestFit

public static float bestFit(float[] x,
                            float[] y,
                            float intercept)
Returns the slope of the best fit linear line for the prescribed y-intercept. That is, z = slope*x + intercept, where the intercept is specified by the user. E.g. intercept = 1 will result in z = slope*x+1. The slope is computed by minimizing the sum of least squares between z and the y.

Parameters:
x - the x data
y - the y data
intercept - the intercept of the best-fit line with the y-axis.
Returns:
the slope of the best-fit linear line.

residuals

public static float[] residuals(float[] x,
                                float[] y,
                                float slope,
                                float intercept)
Compute and return the array of residuals given by Delta_i = z_i - y_i, where z_i = (slope*x_i + intercept) is the best fit linear line.

Parameters:
slope - the slope of the best-fit linear line
intercept - the y-intercept of the best fit linear line

residuals

public static float[] residuals(float[] x,
                                float[] y)
Compute and return the array of residuals given by Delta_i = z_i - y_i, where z_i = (slope*x_i + intercept) is the best fit linear line. You'd basically use this to compute the spread of a best fit line (max - min)



Processing library papaya by Adila Faruk. (C) 2014