Package edu.cmu.tetrad.util
Class RandomPiecewiseLinearBijective
java.lang.Object
edu.cmu.tetrad.util.RandomPiecewiseLinearBijective
Represents a bijective, piecewise linear function whose control points are generated randomly. The function is
defined within a specified domain and range, and it can map values from one interval to another.
- Author:
- GPT 4o., josephramsey
-
Constructor Summary
ConstructorsConstructorDescriptionRandomPiecewiseLinearBijective(int numSegments, long seed) Constructs a RandomPiecewiseLinearBijective object with a specified number of segments and a seed for random generation. -
Method Summary
Modifier and TypeMethodDescriptiondoubleevaluate(double x) Evaluates the piecewise linear bijective function for a given input value.List<double[]> Retrieves the list of control points defining the piecewise linear bijective function.static voidThe entry point of the program that demonstrates the use of the RandomPiecewiseLinearBijective class.voidsetScale(double xMin, double xMax, double yMin, double yMax) Sets the scale of the function by updating the minimum and maximum values of the x-axis and y-axis.
-
Constructor Details
-
RandomPiecewiseLinearBijective
public RandomPiecewiseLinearBijective(int numSegments, long seed) Constructs a RandomPiecewiseLinearBijective object with a specified number of segments and a seed for random generation. This constructor generates control points that define the piecewise linear bijective function.- Parameters:
numSegments- the number of segments to divide the function into; must be at least 1seed- the seed value for random number generation, ensuring reproducibility- Throws:
IllegalArgumentException- if the number of segments is less than 1
-
-
Method Details
-
main
The entry point of the program that demonstrates the use of the RandomPiecewiseLinearBijective class. It initializes a piecewise linear bijective function with randomly generated control points, evaluates it at specific points, and demonstrates scaling the function over a different range.- Parameters:
args- command-line arguments (not used in this program)
-
setScale
public void setScale(double xMin, double xMax, double yMin, double yMax) Sets the scale of the function by updating the minimum and maximum values of the x-axis and y-axis.- Parameters:
xMin- the minimum value for the x-axisxMax- the maximum value for the x-axisyMin- the minimum value for the y-axisyMax- the maximum value for the y-axis
-
evaluate
public double evaluate(double x) Evaluates the piecewise linear bijective function for a given input value. Scales the input value to the range [0, 1], evaluates the function in that range, and then scales the output value back to the specified range [yMin, yMax].- Parameters:
x- the input value to evaluate; must be within the range [xMin, xMax]- Returns:
- the output value of the function, scaled to the range [yMin, yMax]
- Throws:
IllegalArgumentException- if the input x is outside the range [xMin, xMax]
-
getControlPoints
Retrieves the list of control points defining the piecewise linear bijective function. The control points are immutable and represent key points for the function's segments.- Returns:
- an unmodifiable list of control points, each represented as a two-element double array
-