roll back

This commit is contained in:
Roland Grinis 2021-03-31 09:23:41 +01:00
parent 706a44fd33
commit b36281fa39

View File

@ -37,10 +37,8 @@ internal fun Buffer<Double>.array(): DoubleArray = when (this) {
is DoubleBuffer -> array
else -> throw RuntimeException("Failed to cast Buffer to DoubleArray")
}
/*
internal inline fun getRandomNormals(n: Int,): DoubleArray {
val sampler = BoxMullerNormalizedGaussianSampler.of()
val chain = sampler.sample(RandomGenerator.default)
return (0 until n).map { chain.next() }.toDoubleArray()
}
*/
internal inline fun getRandomNormals(n: Int, seed: Long): DoubleArray {
val u = Random(seed)
return (0 until n).map { sqrt(-2.0 * ln(u.nextDouble())) * cos(2.0 * PI * u.nextDouble()) }.toDoubleArray()
}