Package edu.cmu.tetrad.search.utils
Class RandomPiecewiseSpline
java.lang.Object
edu.cmu.tetrad.search.utils.RandomPiecewiseSpline
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
ConstructorsConstructorDescriptionRandomPiecewiseSpline(int numPoints, double xMin, double xMax, double yMin, double yMax) Constructor to initialize a piecewise cubic spline function. -
Method Summary
Modifier and TypeMethodDescriptiondoublecompute(double x) Compute the value of the spline function at a given x.doublecomputeAdjusted(double x) Adjusts the value of the spline function at a given x by subtracting the function's value at x = 0.static voidThe main method serves as the entry point for the program.
-
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
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.
-