Class Distributions

java.lang.Object
com.amalgamasimulation.utils.random.Distributions

public class Distributions extends Object
Utility class for working with RealDistribution objects. Provides string serialization, parsing, and cloning support with new random generators.
Author:
Andrey Malykhanov
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.commons.math3.distribution.RealDistribution
    multipliedBy(org.apache.commons.math3.distribution.RealDistribution distribution, double factor)
    Returns a copy of the given RealDistribution with all relevant parameters multiplied by the specified factor.
    static org.apache.commons.math3.distribution.RealDistribution
    parse(String string)
    Parses a RealDistribution from a string representation.
    static String
    toString(org.apache.commons.math3.distribution.RealDistribution distribution)
    Returns a human-readable, locale-aware string representation of the specified RealDistribution instance.
    static org.apache.commons.math3.distribution.RealDistribution
    withRandomGenerator(org.apache.commons.math3.distribution.RealDistribution distribution, org.apache.commons.math3.random.RandomGenerator randomGenerator)
    Creates a copy of the given RealDistribution, replacing its random number generator with the specified one.

    Methods inherited from class java.lang.Object

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

    • Distributions

      public Distributions()
  • Method Details

    • toString

      public static String toString(org.apache.commons.math3.distribution.RealDistribution distribution)
      Returns a human-readable, locale-aware string representation of the specified RealDistribution instance.
      Parameters:
      distribution - the distribution to serialize
      Returns:
      a string like "normal(0.0; 1.0)" or "5.0" for constants
      Throws:
      UnsupportedOperationException - if the distribution type is not supported
    • parse

      public static org.apache.commons.math3.distribution.RealDistribution parse(String string)
      Parses a RealDistribution from a string representation. Supports both constant values and parameterized forms like normal(0.0; 1.0). Agnostic of decimal point sign.
      Parameters:
      string - the string to parse
      Returns:
      the parsed RealDistribution instance
      Throws:
      IllegalArgumentException - if the format is invalid
      UnsupportedOperationException - if the distribution type is unknown
    • withRandomGenerator

      public static org.apache.commons.math3.distribution.RealDistribution withRandomGenerator(org.apache.commons.math3.distribution.RealDistribution distribution, org.apache.commons.math3.random.RandomGenerator randomGenerator)
      Creates a copy of the given RealDistribution, replacing its random number generator with the specified one.
      Parameters:
      distribution - the original distribution to copy
      randomGenerator - the new RandomGenerator to use
      Returns:
      a new distribution of the same type with identical parameters and the provided random number generator
      Throws:
      UnsupportedOperationException - if the distribution type is not supported
    • multipliedBy

      public static org.apache.commons.math3.distribution.RealDistribution multipliedBy(org.apache.commons.math3.distribution.RealDistribution distribution, double factor)
      Returns a copy of the given RealDistribution with all relevant parameters multiplied by the specified factor.

      This method is useful for scaling distributions, e.g., to convert from one unit to another.

      Parameters:
      distribution - the original distribution
      factor - the scale factor to multiply by
      Returns:
      a new scaled RealDistribution instance
      Throws:
      UnsupportedOperationException - if the distribution type is not supported