MCPcopy Create free account
hub / github.com/esengine/esengine / nextGaussian

Method nextGaussian

packages/procgen/src/random/SeededRandom.ts:110–115  ·  view source on GitHub ↗

* @zh 生成正态分布随机数 (Box-Muller 变换) * @en Generate normally distributed random number (Box-Muller transform) * * @param mean - @zh 均值 @en Mean * @param stdDev - @zh 标准差 @en Standard deviation

(mean: number = 0, stdDev: number = 1)

Source from the content-addressed store, hash-verified

108 * @param stdDev - @zh 标准差 @en Standard deviation
109 */
110 nextGaussian(mean: number = 0, stdDev: number = 1): number {
111 const u1 = this.next();
112 const u2 = this.next();
113 const z0 = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
114 return z0 * stdDev + mean;
115 }
116
117 /**
118 * @zh 生成指数分布随机数

Callers

nothing calls this directly

Calls 2

nextMethod · 0.95
logMethod · 0.45

Tested by

no test coverage detected