File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -38,15 +38,18 @@ def getUniformSample(self):
38
38
return self ._random .random ()
39
39
40
40
def getPoissonSample (self , mean ):
41
- # Using Knuth's algorithm described in http://en.wikipedia.org/wiki/Poisson_distribution
42
- if mean < 20.0 : # one exp and k+1 random calls
41
+ # Using Knuth's algorithm described in
42
+ # http://en.wikipedia.org/wiki/Poisson_distribution
43
+ if mean < 20.0 :
44
+ # one exp and k+1 random calls
43
45
l = math .exp (- mean )
44
46
p = self ._random .random ()
45
47
k = 0
46
48
while p > l :
47
49
k += 1
48
50
p *= self ._random .random ()
49
- else : # switch to the log domain, k+1 expovariate (random + log) calls
51
+ else :
52
+ # switch to the log domain, k+1 expovariate (random + log) calls
50
53
p = self ._random .expovariate (mean )
51
54
k = 0
52
55
while p < 1.0 :
You can’t perform that action at this time.
0 commit comments