Class ModelData


  • public class ModelData
    extends java.lang.Object
    Methods in this class are used to create functions that model experimental data.

    Modified by: Joseph A. Huwaldt

    Version:
    February 13, 2014
    Author:
    Joseph A. Huwaldt Date: October 21, 2002
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelData()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double fit​(double[] xarr, double[] yarr, double[] sig, BasisFunction func, double[] coef)
      Method that returns the coefficients of an arbitrary basis function that best models or "fits" the supplied data values in a minimization of chi-squared sense.
      static double linearSlope​(double[] x, double[] y)
      Returns the slope of the line formed by a linear regression through the specified data arrays.
      static void main​(java.lang.String[] args)
      Used to test the methods in this class.
      static double polynomial​(double[] xarr, double[] yarr, double[] coef)
      Method that returns the coefficients of a polynomial of the specified degree that best models or "fits" the supplied data values in a minimization of chi-squared sense.
      static double polynomial​(double[] xarr, double[] yarr, double[] sig, double[] coef)
      Method that returns the coefficients of a polynomial of the specified degree that best models or "fits" the supplied data values in a minimization of chi-squared sense.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • polynomial

        public static double polynomial​(double[] xarr,
                                        double[] yarr,
                                        double[] coef)
                                 throws RootException
        Method that returns the coefficients of a polynomial of the specified degree that best models or "fits" the supplied data values in a minimization of chi-squared sense. This method assumes that each data point is normally distributed and has a standard deviation of 1.0.
        Parameters:
        xarr - Array of independent parameter data values to fit.
        yarr - Array of dependent data values (associated with each X value) to be modeled.
        coef - An existing array that will be filled in with the coefficients of the polynomial, in decreasing power that best fits the sample data. Example: p(x) = A + B*x + C*x^2 + D*x^3 + E*x^4 corresponds to coef[] = {A, B, C, D, E}. The number of elements in the coef array determines the order of the polynomial created. Number of elements be greater than 1.
        Returns:
        The chi-squared value of the polynomial returned. A value near zero indicates a perfect fit.
        Throws:
        RootException
      • polynomial

        public static double polynomial​(double[] xarr,
                                        double[] yarr,
                                        double[] sig,
                                        double[] coef)
                                 throws RootException
        Method that returns the coefficients of a polynomial of the specified degree that best models or "fits" the supplied data values in a minimization of chi-squared sense.
        Parameters:
        xarr - Array of independent parameter data values to fit.
        yarr - Array of dependent data values (associated with each X value) to be modeled.
        sig - Array of individual standard deviations for each data point.
        coef - An existing array that will be filled in with the coefficients of the polynomial, in decreasing power that best fits the sample data. Example: p(x) = A + B*x + C*x^2 + D*x^3 + E*x^4 corresponds to coef[] = {A, B, C, D, E}. The number of elements in the coef array determines the order of the polynomial created. Number of elements be greater than 1.
        Returns:
        The chi-squared value of the polynomial returned. A value near zero indicates a perfect fit.
        Throws:
        RootException
      • fit

        public static double fit​(double[] xarr,
                                 double[] yarr,
                                 double[] sig,
                                 BasisFunction func,
                                 double[] coef)
                          throws RootException
        Method that returns the coefficients of an arbitrary basis function that best models or "fits" the supplied data values in a minimization of chi-squared sense.
        Parameters:
        xarr - Array of independent parameter data values to fit.
        yarr - Array of dependent data values (associated with each X value) to be modeled.
        sig - Array of individual standard deviations for each data point.
        func - The basis function used to generate the data fit.
        coef - An existing array that will be filled in with the coefficients of the basis function that best fits the data.
        Returns:
        The chi-squared value of the function is returned. A value near zero indicates a perfect fit.
        Throws:
        RootException
      • linearSlope

        public static double linearSlope​(double[] x,
                                         double[] y)
        Returns the slope of the line formed by a linear regression through the specified data arrays.
        Parameters:
        x - The independent array of data points.
        y - The dependent array of data points (must be the same size as the x array.
        Returns:
        The slope of the line formed by a linear regression through the x and y arrays of data points.
      • main

        public static void main​(java.lang.String[] args)
        Used to test the methods in this class.