From 5c438d7299858afde917f47be63fec17a1d9b359 Mon Sep 17 00:00:00 2001 From: Davies Liu Date: Thu, 20 Nov 2014 14:18:22 -0800 Subject: [PATCH] fix comment --- python/pyspark/rddsampler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/pyspark/rddsampler.py b/python/pyspark/rddsampler.py index 9e7acc28e99dd..459e1427803cb 100644 --- a/python/pyspark/rddsampler.py +++ b/python/pyspark/rddsampler.py @@ -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: