Class Distributions
java.lang.Object
com.amalgamasimulation.utils.random.Distributions
Utility class for working with
RealDistribution objects. Provides
string serialization, parsing, and cloning support with new random
generators.- Author:
- Andrey Malykhanov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.commons.math3.distribution.RealDistributionmultipliedBy(org.apache.commons.math3.distribution.RealDistribution distribution, double factor) Returns a copy of the givenRealDistributionwith all relevant parameters multiplied by the specifiedfactor.static org.apache.commons.math3.distribution.RealDistributionParses aRealDistributionfrom a string representation.static StringtoString(org.apache.commons.math3.distribution.RealDistribution distribution) Returns a human-readable, locale-aware string representation of the specifiedRealDistributioninstance.static org.apache.commons.math3.distribution.RealDistributionwithRandomGenerator(org.apache.commons.math3.distribution.RealDistribution distribution, org.apache.commons.math3.random.RandomGenerator randomGenerator) Creates a copy of the givenRealDistribution, replacing its random number generator with the specified one.
-
Constructor Details
-
Distributions
public Distributions()
-
-
Method Details
-
toString
Returns a human-readable, locale-aware string representation of the specifiedRealDistributioninstance.- 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
Parses aRealDistributionfrom a string representation. Supports both constant values and parameterized forms likenormal(0.0; 1.0). Agnostic of decimal point sign.- Parameters:
string- the string to parse- Returns:
- the parsed
RealDistributioninstance - Throws:
IllegalArgumentException- if the format is invalidUnsupportedOperationException- 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 givenRealDistribution, replacing its random number generator with the specified one.- Parameters:
distribution- the original distribution to copyrandomGenerator- the newRandomGeneratorto 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 givenRealDistributionwith all relevant parameters multiplied by the specifiedfactor.This method is useful for scaling distributions, e.g., to convert from one unit to another.
- Parameters:
distribution- the original distributionfactor- the scale factor to multiply by- Returns:
- a new scaled
RealDistributioninstance - Throws:
UnsupportedOperationException- if the distribution type is not supported
-