API reference / @jsprismarine/worldgen / MarsagliaPolarGaussian
Class: MarsagliaPolarGaussian
Defined in: random/MarsagliaPolarGaussian.ts:9
The Marsaglia polar method Java Edition uses for nextGaussian.
It produces two values per rejection loop and hands out the second on the following call, so the number of nextDouble draws a caller consumes depends on how many calls came before.
Constructors
Constructor
new MarsagliaPolarGaussian(
randomSource):MarsagliaPolarGaussian
Defined in: random/MarsagliaPolarGaussian.ts:13
Parameters
randomSource
Returns
MarsagliaPolarGaussian
Methods
nextGaussian()
nextGaussian():
number
Defined in: random/MarsagliaPolarGaussian.ts:50
Returns the next normally distributed value with mean 0 and standard deviation 1.
Returns
number
reset()
reset():
void
Defined in: random/MarsagliaPolarGaussian.ts:16
Forgets the cached second value, as Java does when a source is reseeded.
Returns
void
restoreState()
restoreState(
state):void
Defined in: random/MarsagliaPolarGaussian.ts:30
Restores the cached half of a Gaussian draw from a JSON-parsed value.
Parameters
state
unknown
Returns
void
saveState()
saveState():
GaussianCacheState
Defined in: random/MarsagliaPolarGaussian.ts:21
Returns the cached second value, if the next call can use it without drawing.