Class RandomFourier

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

public class RandomFourier extends Object
The RandomFourier class generates a random Fourier series with specified cosine and sine amplitudes and frequency terms. The series is defined as:

f(x) = Σ [a_i * cos(b_i * x) + c_i * sin(b_i * x)]

where: - a_i and c_i are randomly chosen amplitudes in the range [-2, 2], - b_i are randomly chosen frequencies scaled by a given factor.

This class also provides functionality to adjust the series so that its value at x = 0 is zero.

  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomFourier(int numTerms, double frequencyScale)
    Initializes a RandomFourier instance with the specified number of terms and frequency scale.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    compute(double x)
    Computes the value of the Fourier series at a given input x.
    double
    computeAdjusted(double x)
    Computes the adjusted value of the Fourier series at the given input x.
    static void
    main(String[] args)
    The main method demonstrates the usage of the RandomFourier class.

    Methods inherited from class java.lang.Object

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

    • RandomFourier

      public RandomFourier(int numTerms, double frequencyScale)
      Initializes a RandomFourier instance with the specified number of terms and frequency scale.
      Parameters:
      numTerms - The number of terms in the Fourier series.
      frequencyScale - The scale factor applied to the randomly generated frequencies.
  • Method Details

    • main

      public static void main(String[] args)
      The main method demonstrates the usage of the RandomFourier class. It creates an instance of RandomFourier, evaluates the adjusted Fourier series over a given range of x values, and verifies that the series is adjusted such that its value at x = 0 is approximately zero.
      Parameters:
      args - Command-line arguments (not used in this implementation).
    • compute

      public double compute(double x)
      Computes the value of the Fourier series at a given input x.
      Parameters:
      x - The input value for which the Fourier series is evaluated.
      Returns:
      The calculated result of the Fourier series at the given input x.
    • computeAdjusted

      public double computeAdjusted(double x)
      Computes the adjusted value of the Fourier series at the given input x. The adjustment ensures that the computed value is shifted such that the Fourier series value at x = 0 is zero.
      Parameters:
      x - The input value for which the adjusted Fourier series is evaluated.
      Returns:
      The adjusted result of the Fourier series at the given input x.