Class RandomPiecewiseSpline

java.lang.Object
edu.cmu.tetrad.search.utils.RandomPiecewiseSpline

public class RandomPiecewiseSpline extends Object
This class generates and evaluates a random piecewise cubic spline function. It uses a set of breakpoints and random y-values to create the spline. A cubic spline interpolator is then used to compute the interpolated values for input x-values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomPiecewiseSpline(int numPoints, double xMin, double xMax, double yMin, double yMax)
    Constructor to initialize a piecewise cubic spline function.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    compute(double x)
    Compute the value of the spline function at a given x.
    double
    computeAdjusted(double x)
    Adjusts the value of the spline function at a given x by subtracting the function's value at x = 0.
    static void
    main(String[] args)
    The main method serves as the entry point for the program.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomPiecewiseSpline

      public RandomPiecewiseSpline(int numPoints, double xMin, double xMax, double yMin, double yMax)
      Constructor to initialize a piecewise cubic spline function.
      Parameters:
      numPoints - Number of breakpoints for the spline.
      xMin - Minimum x-value for the domain.
      xMax - Maximum x-value for the domain.
      yMin - Minimum y-value for the range.
      yMax - Maximum y-value for the range.
  • Method Details

    • main

      public static void main(String[] args)
      The main method serves as the entry point for the program. It creates an instance of RandomPiecewiseSpline and evaluates the spline function for a range of x-values. The results are printed to the console.
      Parameters:
      args - Command-line arguments passed to the program (not used in this implementation).
    • compute

      public double compute(double x)
      Compute the value of the spline function at a given x.
      Parameters:
      x - The x-value where the function is evaluated.
      Returns:
      The interpolated y-value.
    • computeAdjusted

      public double computeAdjusted(double x)
      Adjusts the value of the spline function at a given x by subtracting the function's value at x = 0.
      Parameters:
      x - The x-value where the adjusted computation is performed.
      Returns:
      The adjusted value of the spline function at the given x.