Update comments

This commit is contained in:
DBotThePony 2025-01-22 13:27:13 +07:00
parent 1a50ecd6af
commit b4c8676daa
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -597,7 +597,7 @@ infix fun FluidStack.isNotSameAs(other: FluidStack): Boolean {
data class DoublePair(val first: Double, val second: Double)
// normal distribution via Box-Muller
// normal distribution via Marsaglia polar method
fun RandomGenerator.nextNormalDoubles(stddev: Double, mean: Double): DoublePair {
var rand1: Double
var rand2: Double
@ -607,7 +607,7 @@ fun RandomGenerator.nextNormalDoubles(stddev: Double, mean: Double): DoublePair
rand1 = 2.0 * nextDouble() - 1.0
rand2 = 2.0 * nextDouble() - 1.0
distSqr = rand1 * rand1 + rand2 * rand2
} while (distSqr >= 1)
} while (distSqr >= 1.0 || distSqr == 0.0)
val mapping = sqrt(-2.0 * ln(distSqr) / distSqr)
@ -617,8 +617,7 @@ fun RandomGenerator.nextNormalDoubles(stddev: Double, mean: Double): DoublePair
)
}
// All Mojang's random sources use MarsagliaPolarGaussian for generating normal distributed doubles,
// which is Box-Muller transform already, so we can use that
// All Mojang's random sources use MarsagliaPolarGaussian for generating normal distributed doubles
fun RandomSource.nextNormalDoubles(stddev: Double, mean: Double): DoublePair {
return DoublePair(
nextGaussian() * stddev + mean,