Class RandomPiecewiseLinearBijective

java.lang.Object
edu.cmu.tetrad.util.RandomPiecewiseLinearBijective

public class RandomPiecewiseLinearBijective extends Object
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

    Constructors
    Constructor
    Description
    RandomPiecewiseLinearBijective(int numSegments, long seed)
    Constructs a RandomPiecewiseLinearBijective object with a specified number of segments and a seed for random generation.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    evaluate(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 void
    main(String[] args)
    The entry point of the program that demonstrates the use of the RandomPiecewiseLinearBijective class.
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 1
      seed - the seed value for random number generation, ensuring reproducibility
      Throws:
      IllegalArgumentException - if the number of segments is less than 1
  • Method Details

    • main

      public static void main(String[] args)
      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-axis
      xMax - the maximum value for the x-axis
      yMin - the minimum value for the y-axis
      yMax - 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

      public List<double[]> 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