Package squidpony.squidmath
Class GaussianDistribution
java.lang.Object
squidpony.squidmath.GaussianDistribution
- All Implemented Interfaces:
IDistribution
public class GaussianDistribution extends Object implements IDistribution
An IDistribution that produces double results with a Gaussian (normal) distribution. This means it has no limits in
any direction, but is much more likely to produce results close to 0. It uses the Ziggurat method, as published by
Marsaglia and Tsang, 2000, in "The Ziggurat Method for Generating Random Variables";
pdf link. The code here is a port from the random number section
of Go-Lang's experimental standard library.
Created by Tommy Ettinger on 11/23/2019, porting normal.go from https://github.com/golang/exp .
Created by Tommy Ettinger on 11/23/2019, porting normal.go from https://github.com/golang/exp .
-
Nested Class Summary
Nested classes/interfaces inherited from interface squidpony.squidmath.IDistribution
IDistribution.SimpleDistribution -
Field Summary
Fields Modifier and Type Field Description static GaussianDistributioninstance -
Constructor Summary
Constructors Constructor Description GaussianDistribution() -
Method Summary
Modifier and Type Method Description doublegetLowerBound()The lower inclusive bound is negative infinity.doublegetUpperBound()The upper inclusive bound is infinity.doublenextDouble(IRNG rng)Gets a double betweenIDistribution.getLowerBound()andIDistribution.getUpperBound()that obeys this distribution.
-
Field Details
-
Constructor Details
-
GaussianDistribution
public GaussianDistribution()
-
-
Method Details
-
nextDouble
Description copied from interface:IDistributionGets a double betweenIDistribution.getLowerBound()andIDistribution.getUpperBound()that obeys this distribution.- Specified by:
nextDoublein interfaceIDistribution- Parameters:
rng- an IRNG, such asRNGorGWTRNG, that this will get one or more random numbers from- Returns:
- a double within the range of
IDistribution.getLowerBound()andIDistribution.getUpperBound()
-
getLowerBound
The lower inclusive bound is negative infinity.- Specified by:
getLowerBoundin interfaceIDistribution- Returns:
- negative infinity
-
getUpperBound
The upper inclusive bound is infinity.- Specified by:
getUpperBoundin interfaceIDistribution- Returns:
- positive infinity
-