com.jrefinery.data
Class Statistics

java.lang.Object
  extended by com.jrefinery.data.Statistics

public class Statistics
extends java.lang.Object

A utility class that provides some simple statistical functions.


Constructor Summary
Statistics()
           
 
Method Summary
static double getAverage(java.lang.Number[] data)
          Returns the average of a set of numbers.
static double getCorrelation(java.lang.Number[] data1, java.lang.Number[] data2)
          Calculates the correlation between two datasets.
static double[] getLinearFit(java.lang.Number[] x_data, java.lang.Number[] y_data)
          Fits a straight line to a set of (x, y) data, returning the slope and intercept.
static double[][] getMovingAverage(java.lang.Number[] x_data, java.lang.Number[] y_data, int period)
          Returns a data set for a moving average on the data set passed in.
static double getSlope(java.lang.Number[] x_data, java.lang.Number[] y_data)
          Finds the slope of a regression line using least squares.
static double getStdDev(java.lang.Number[] data)
          Returns the standard deviation of a set of numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statistics

public Statistics()
Method Detail

getAverage

public static double getAverage(java.lang.Number[] data)
Returns the average of a set of numbers.

Parameters:
data - The data.

getStdDev

public static double getStdDev(java.lang.Number[] data)
Returns the standard deviation of a set of numbers.

Parameters:
data - The data.

getLinearFit

public static double[] getLinearFit(java.lang.Number[] x_data,
                                    java.lang.Number[] y_data)
Fits a straight line to a set of (x, y) data, returning the slope and intercept.

Parameters:
x_data - The x-data.
y_data - The y-data.
Returns:
A double array with the intercept in [0] and the slope in [1].

getSlope

public static double getSlope(java.lang.Number[] x_data,
                              java.lang.Number[] y_data)
Finds the slope of a regression line using least squares.

Parameters:
x_data - An array of Numbers (the x values).
y_data - An array of Numbers (the y values).

getCorrelation

public static double getCorrelation(java.lang.Number[] data1,
                                    java.lang.Number[] data2)
Calculates the correlation between two datasets.

Parameters:
data1 - The first dataset.
data2 - The second dataset.

getMovingAverage

public static double[][] getMovingAverage(java.lang.Number[] x_data,
                                          java.lang.Number[] y_data,
                                          int period)
Returns a data set for a moving average on the data set passed in.

Parameters:
x_data - An array of the x data.
y_data - An array of the y data.
period - The number of data points to average
Returns:
A double[][] the length of the data set in the first dimension, with two doubles for x and y in the second dimension


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.