Mention thread-safety
This commit is contained in:
parent
e315734381
commit
32dbdc860b
|
@ -12,8 +12,9 @@
|
||||||
|
|
||||||
import math, random
|
import math, random
|
||||||
|
|
||||||
proc normal_distribution(mean = 0.0, std = 1.0): int =
|
proc normal_distribution*(mean = 0.0, std = 1.0): int =
|
||||||
## Return an integer sampled from a normal distribution (gaussian)
|
## Return an integer sampled from a normal distribution (gaussian)
|
||||||
|
## ⚠ This is not thread-safe
|
||||||
# Implementation via the Box-Muller method
|
# Implementation via the Box-Muller method
|
||||||
# See https://en.wikipedia.org/wiki/Box–Muller_transform
|
# See https://en.wikipedia.org/wiki/Box–Muller_transform
|
||||||
|
|
||||||
|
@ -34,7 +35,6 @@ proc normal_distribution(mean = 0.0, std = 1.0): int =
|
||||||
z1 = R * sin(2 * PI * u2)
|
z1 = R * sin(2 * PI * u2)
|
||||||
return int(z0 * std + mean)
|
return int(z0 * std + mean)
|
||||||
|
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import sequtils, stats, strformat
|
import sequtils, stats, strformat
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue