Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Nov 20, 2014
1 parent c5b9252 commit 5c438d7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/pyspark/rddsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ def getUniformSample(self):
return self._random.random()

def getPoissonSample(self, mean):
# Using Knuth's algorithm described in http://en.wikipedia.org/wiki/Poisson_distribution
if mean < 20.0: # one exp and k+1 random calls
# Using Knuth's algorithm described in
# http://en.wikipedia.org/wiki/Poisson_distribution
if mean < 20.0:
# one exp and k+1 random calls
l = math.exp(-mean)
p = self._random.random()
k = 0
while p > l:
k += 1
p *= self._random.random()
else: # switch to the log domain, k+1 expovariate (random + log) calls
else:
# switch to the log domain, k+1 expovariate (random + log) calls
p = self._random.expovariate(mean)
k = 0
while p < 1.0:
Expand Down

0 comments on commit 5c438d7

Please sign in to comment.