Class Integrate1DNumeric

java.lang.Object
ffx.numerics.integrate.Integrate1DNumeric

public class Integrate1DNumeric extends Object
This program integrates using four methods: rectangular integration, the trapezoidal method, Simpson's Three Point Integration, and Boole's Five Point Integration. Of these, Simpson's and Boole's integration methods generally perform the best. Parallelized methods exist and seem to function, but the performance of a parallelized method should not be necessary, and the parallelization introduces some complexity and inefficiency.

Primary methods: integrateData and integrateByBins, using some DataSet, which is often a DoublesDataSet.

Author:
Claire O'Connell, Jacob M. Litman
  • Method Details

    • booles

      public static double booles(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using Boole's rule.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • booles

      public static double booles(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using Boole's rule.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • boolesParallel

      public static double boolesParallel(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using Boole's rule. The sequential version is preferred unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • boolesParallel

      public static double boolesParallel(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using Boole's rule. The sequential version is preferred unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • generateXPoints

      public static double[] generateXPoints(double lb, double ub, int nPoints, boolean halfWidthEnds)
      Generates a set of points along x.
      Parameters:
      lb - Beginning value, inclusive
      ub - Ending value, inclusive
      nPoints - Total number of points
      halfWidthEnds - If ends should have 1/2 regular separation
      Returns:
      an array of
      invalid reference
      double
      objects.
    • integrateByBins

      public static double[] integrateByBins(DataSet data, Integrate1DNumeric.IntegrationSide side, Integrate1DNumeric.IntegrationType maxType)
      Returns the contribution of each bin to the overall integral as an array; will be most accurate at break-points for the integration type. Overall integral is the sum of the array of doubles, plus or minus minor rounding errors.

      If N is a breakpoint for Boole's rule: N+1 is a trapezoid from N to N+1. N+2 is Simpson's from N to N+2, minus the prior trapezoid (N+1). N+3 is 4-point integration from N to N+3, minus the N to N+2 parabola. N+4 is the full Boole's Rule from N to N+4, minus the N to N+3 4-point integral.

      Parameters:
      data - Data to integrate
      side - Side to integrate from
      maxType - Maximum rule to be used
      Returns:
      Per-bin contributions to integral.
    • integrateData

      public static double integrateData(DataSet data, Integrate1DNumeric.IntegrationSide side, Integrate1DNumeric.IntegrationType type)
      Generic caller for 1D integration schemes given an IntegrationType.
      Parameters:
      data - To integrate
      side - Integrate from side
      type - Scheme to use
      Returns:
      Numeric integral
    • rectangular

      public static double rectangular(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using rectangular integration. Not recommended; preferably use at least trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • rectangular

      public static double rectangular(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using rectangular integration. Not recommended; preferably use at least trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • rectangularEnds

      public static double rectangularEnds(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Treats half-width bins at the ends of a DataSet using rectangular integration. Not recommended, preferably use trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Estimate of area in half-width start/end bins.
    • rectangularParallel

      public static double rectangularParallel(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using parallelized rectangular integration. Not recommended; preferably use at least trapezoidal integration, and avoid parallelized versions unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • rectangularParallel

      public static double rectangularParallel(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using rectangular integration. Not recommended; preferably use at least trapezoidal integration. Also, prefer parallelized versions unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • simpsons

      public static double simpsons(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using Simpson's rule.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • simpsons

      public static double simpsons(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using Simpson's rule.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • simpsonsParallel

      public static double simpsonsParallel(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using Boole's rule. The sequential version is preferred unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • simpsonsParallel

      public static double simpsonsParallel(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using Simpson's rule. The sequential version is preferred unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • trapezoidal

      public static double trapezoidal(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using trapezoidal integration. For most data sets, Simpson's rule or Boole's rule will out-perform trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • trapezoidal

      public static double trapezoidal(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using trapezoidal integration. For most data sets, Simpson's rule or Boole's rule will out-perform trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral
    • trapezoidalEnds

      public static double trapezoidalEnds(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Treats half-width bins at the ends of a DataSet using trapezoidal integration.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Estimate of area in half-width start/end bins.
    • trapezoidalParallel

      public static double trapezoidalParallel(DataSet data, Integrate1DNumeric.IntegrationSide side)
      Numerically integrates a data set using trapezoidal integration. For most data sets, Simpson's rule or Boole's rule will out-perform trapezoidal integration. Prefer use of the sequential version unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      Returns:
      Area of integral
    • trapezoidalParallel

      public static double trapezoidalParallel(DataSet data, Integrate1DNumeric.IntegrationSide side, int lb, int ub)
      Numerically integrates a data set, in bounds lb-ub inclusive, using trapezoidal integration. For most data sets, Simpson's rule or Boole's rule will out-perform trapezoidal integration. Prefer use of the sequential version unless necessary.
      Parameters:
      data - Data set to integrate
      side - Side to integrate from
      lb - First index to integrate over
      ub - Last index to integrate over
      Returns:
      Area of integral