umontreal.iro.lecuyer.probdist
Class DistributionFactory
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DistributionFactory
-
public class DistributionFactory extends java.lang.ObjectThis class implements a string API for the package probdist. It uses Java Reflection to allow the creation of probability distribution objects from a string. This permits one to obtain distribution specifications from a file or dynamically from user input during program execution. This string API is similar to that of UNURAN.The (static) methods of this class invoke the constructor specified in the string. For example,
d = DistributionFactory.getContinuousDistribution ("NormalDist (0.0, 2.5)");is equivalent to
d = NormalDist (0.0, 2.5);
The string that specifies the distribution (i.e., the formal parameter str of the methods) must be a valid call of the constructor of a class that extends
ContinuousDistributionorDiscreteDistribution, and all parameter values must be numerical values (variable names are not allowed).The distribution parameters can also be estimated from a set of observations instead of being passed to the constructor. In that case, one passes the vector of observations, and the constructor estimates the parameters by the maximum likelihood method.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static ContinuousDistributiongetContinuousDistribution(java.lang.String str)Uses the Java Reflection API to construct aContinuousDistributionobject by executing the code contained in the string str.static DiscreteDistributiongetDiscreteDistribution(java.lang.String str)Same asgetContinuousDistribution, but for discrete distributions over the real numbers.static DiscreteDistributionIntgetDiscreteDistributionInt(java.lang.String str)Same asgetContinuousDistribution, but for discrete distributions over the integers.static DistributiongetDistribution(java.lang.String str)static <T extends ContinuousDistribution>
TgetDistributionMLE(java.lang.Class<T> distClass, double[] x, int n)static <T extends DiscreteDistributionInt>
TgetDistributionMLE(java.lang.Class<T> distClass, int[] x, int n)static ContinuousDistributiongetDistributionMLE(java.lang.String distName, double[] x, int n)static DiscreteDistributionIntgetDistributionMLE(java.lang.String distName, int[] x, int n)
-
-
-
Method Detail
-
getDistribution
public static Distribution getDistribution(java.lang.String str)
-
getDistributionMLE
public static ContinuousDistribution getDistributionMLE(java.lang.String distName, double[] x, int n)
-
getDistributionMLE
public static DiscreteDistributionInt getDistributionMLE(java.lang.String distName, int[] x, int n)
-
getDistributionMLE
public static <T extends ContinuousDistribution> T getDistributionMLE(java.lang.Class<T> distClass, double[] x, int n)
-
getDistributionMLE
public static <T extends DiscreteDistributionInt> T getDistributionMLE(java.lang.Class<T> distClass, int[] x, int n)
-
getContinuousDistribution
public static ContinuousDistribution getContinuousDistribution(java.lang.String str)
Uses the Java Reflection API to construct aContinuousDistributionobject by executing the code contained in the string str. This code should be a valid invocation of the constructor of aContinuousDistributionobject. This method throws exceptions if it cannot parse the given string and returns null if the distribution object could not be created due to a Java-specific instantiation problem.- Parameters:
str- string that contains a call to the constructor of a continuous distribution- Returns:
- a continuous distribution object or null if it could not be instantiated
- Throws:
java.lang.IllegalArgumentException- if parsing problems occured when reading strjava.lang.ClassCastException- if the distribution string does not represent a continuous distribution
-
getDiscreteDistribution
public static DiscreteDistribution getDiscreteDistribution(java.lang.String str)
Same asgetContinuousDistribution, but for discrete distributions over the real numbers.- Parameters:
str- string that contains a call to the constructor of a discrete distribution- Returns:
- a discrete distribution object, or null if it could not be instantiated
- Throws:
java.lang.IllegalArgumentException- if parsing problems occured when reading strjava.lang.ClassCastException- if the distribution string does not represent a discrete distribution
-
getDiscreteDistributionInt
public static DiscreteDistributionInt getDiscreteDistributionInt(java.lang.String str)
Same asgetContinuousDistribution, but for discrete distributions over the integers.- Parameters:
str- string that contains a call to the constructor of a discrete distribution- Returns:
- a discrete distribution object, or null if it could not be instantiated
- Throws:
java.lang.IllegalArgumentException- if parsing problems occured when reading strjava.lang.ClassCastException- if the distribution string does not represent a discrete distribution
-
-
DMelt 3.0 © DataMelt by jWork.ORG