Class KnobDistribution
java.lang.Object
com.github.tommyettinger.random.distribution.Distribution
com.github.tommyettinger.random.distribution.KnobDistribution
A three-parameter distribution with infinite range, which allows interpolating between a
This provides an extra "knob" to slide between a flat uniform distribution and a central-biased normal one.
normal distribution and a uniform distribution.
The first two parameters control mu and sigma for the normal distribution, and also affect alpha and beta for
the uniform one (though differently). The amount of interpolation is the third parameter, called iota here.
This provides an extra "knob" to slide between a flat uniform distribution and a central-biased normal one.
-
Field Summary
Fields inherited from class com.github.tommyettinger.random.distribution.Distribution
generator -
Constructor Summary
ConstructorsConstructorDescriptionUses anAceRandom, mu = 0.0, sigma = 1.0, iota = 0.5 .KnobDistribution(double mu, double sigma, double iota) Uses anAceRandomand the given mu sigma, and iota.KnobDistribution(EnhancedRandom generator, double mu, double sigma, double iota) Uses the given EnhancedRandom directly. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns an exact copy of this Distribution, with the same parameters and a copy of the generator.doublegetIota()doubleGets the maximum possible value of distributed random numbers.doublegetMean()Gets the mean of distributed random numbers.doubleGets the median of distributed random numbers.doubleGets the minimum possible value of distributed random numbers.double[]getMode()Gets the mode(s) of distributed random numbers.doublegetMu()doubleGets the value of parameter "A" as a double.doubleGets the value of parameter "B" as a double.doubleGets the value of parameter "C" as a double.doublegetSigma()getTag()Gets the tag used to identify this type of Distribution, as a String.doubleGets the variance of distributed random numbers.doubleGenerates a double using this distribution.static doublesample(EnhancedRandom generator, double mu, double sigma, double iota) booleansetParameters(double a, double b, double c) Sets all parameters and returns true if they are valid, otherwise leaves parameters unchanged and returns false.Methods inherited from class com.github.tommyettinger.random.distribution.Distribution
appendSerialized, appendSerialized, equals, stringDeserialize, stringDeserialize, stringSerialize, stringSerialize, toString
-
Constructor Details
-
KnobDistribution
public KnobDistribution()Uses anAceRandom, mu = 0.0, sigma = 1.0, iota = 0.5 . -
KnobDistribution
public KnobDistribution(double mu, double sigma, double iota) Uses anAceRandomand the given mu sigma, and iota. -
KnobDistribution
Uses the given EnhancedRandom directly. Uses the given mu, sigma, and iota.
-
-
Method Details
-
getTag
Description copied from class:DistributionGets the tag used to identify this type of Distribution, as a String. This tag should be unique. Unlike the tags for EnhancedRandom types, the names here can vary in length.- Specified by:
getTagin classDistribution- Returns:
- a unique String identifier for this type of Distribution; must be non-null, can be any non-zero length
-
copy
Description copied from class:DistributionReturns an exact copy of this Distribution, with the same parameters and a copy of the generator.- Specified by:
copyin classDistribution- Returns:
- an exact copy of this Distribution
-
getMu
public double getMu() -
getSigma
public double getSigma() -
getIota
public double getIota() -
getParameterA
public double getParameterA()Description copied from class:DistributionGets the value of parameter "A" as a double. This corresponds to parameter "A" inDistribution.setParameters(double, double, double); it is usually called by some other name in the generator, and may not be stored as a double internally.
This defaults to always returningDouble.NaN, but any parameters a distribution actually uses should be overridden to return the actual parameter, which is almost certainly not going to be NaN. If a getParameter method returns NaN, you can generally safely assume that the parameter is not used by this distribution.- Overrides:
getParameterAin classDistribution- Returns:
- the value of parameter "A" as a double.
-
getParameterB
public double getParameterB()Description copied from class:DistributionGets the value of parameter "B" as a double. This corresponds to parameter "B" inDistribution.setParameters(double, double, double); it is usually called by some other name in the generator, and may not be stored as a double internally.
This defaults to always returningDouble.NaN, but any parameters a distribution actually uses should be overridden to return the actual parameter, which is almost certainly not going to be NaN. If a getParameter method returns NaN, you can generally safely assume that the parameter is not used by this distribution.- Overrides:
getParameterBin classDistribution- Returns:
- the value of parameter "B" as a double.
-
getParameterC
public double getParameterC()Description copied from class:DistributionGets the value of parameter "C" as a double. This corresponds to parameter "C" inDistribution.setParameters(double, double, double); it is usually called by some other name in the generator, and may not be stored as a double internally.
This defaults to always returningDouble.NaN, but any parameters a distribution actually uses should be overridden to return the actual parameter, which is almost certainly not going to be NaN. If a getParameter method returns NaN, you can generally safely assume that the parameter is not used by this distribution.- Overrides:
getParameterCin classDistribution- Returns:
- the value of parameter "C" as a double.
-
getMaximum
public double getMaximum()Description copied from class:DistributionGets the maximum possible value of distributed random numbers.- Specified by:
getMaximumin classDistribution- Returns:
- the maximum possible value of distributed random numbers
-
getMean
public double getMean()Description copied from class:DistributionGets the mean of distributed random numbers.- Specified by:
getMeanin classDistribution- Returns:
- the mean of distributed random numbers
-
getMedian
public double getMedian()Description copied from class:DistributionGets the median of distributed random numbers.- Specified by:
getMedianin classDistribution- Returns:
- the median of distributed random numbers
-
getMinimum
public double getMinimum()Description copied from class:DistributionGets the minimum possible value of distributed random numbers.- Specified by:
getMinimumin classDistribution- Returns:
- the minimum possible value of distributed random numbers
-
getMode
public double[] getMode()Description copied from class:DistributionGets the mode(s) of distributed random numbers.- Specified by:
getModein classDistribution- Returns:
- the mode(s) of distributed random numbers
-
getVariance
public double getVariance()Description copied from class:DistributionGets the variance of distributed random numbers.- Specified by:
getVariancein classDistribution- Returns:
- the variance of distributed random numbers
-
setParameters
public boolean setParameters(double a, double b, double c) Sets all parameters and returns true if they are valid, otherwise leaves parameters unchanged and returns false.- Specified by:
setParametersin classDistribution- Parameters:
a- mu; must not be NaNb- sigma; should be greater than 0.0c- iota; must be between 0.0 and 1.0, both inclusive- Returns:
- true if the parameters given are valid and will be used
-
nextDouble
public double nextDouble()Description copied from class:DistributionGenerates a double using this distribution.- Specified by:
nextDoublein classDistribution- Returns:
- a distributed double
-
sample
-