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 GaussianDistribution
instance
-
Constructor Summary
Constructors Constructor Description GaussianDistribution()
-
Method Summary
Modifier and Type Method Description double
getLowerBound()
The lower inclusive bound is negative infinity.double
getUpperBound()
The upper inclusive bound is infinity.double
nextDouble(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:IDistribution
Gets a double betweenIDistribution.getLowerBound()
andIDistribution.getUpperBound()
that obeys this distribution.- Specified by:
nextDouble
in interfaceIDistribution
- Parameters:
rng
- an IRNG, such asRNG
orGWTRNG
, 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:
getLowerBound
in interfaceIDistribution
- Returns:
- negative infinity
-
getUpperBound
The upper inclusive bound is infinity.- Specified by:
getUpperBound
in interfaceIDistribution
- Returns:
- positive infinity
-