[
https://issues.apache.org/jira/browse/FLINK-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14736072#comment-14736072
]
ASF GitHub Bot commented on FLINK-2533:
---------------------------------------
Github user ChengXiangLi commented on a diff in the pull request:
https://github.com/apache/flink/pull/1110#discussion_r39003867
--- Diff:
flink-java/src/main/java/org/apache/flink/api/java/sampling/PoissonSampler.java
---
@@ -93,29 +98,59 @@ public boolean hasNext() {
}
}
}
-
- private void moveToNextElement() {
- while (input.hasNext()) {
+
+ public int poisson_ge1(double p){
+ // sample 'k' from Poisson(p), conditioned to k
>= 1
+ double q = Math.pow(Math.E, -p);
+ // simulate a poisson trial such that k >= 1
+ double t = q + (1 - q)*random.nextDouble();
+ int k = 1;
+ // continue standard poisson generation trials
+ t = t * random.nextDouble();
+ while (t > q) {
+ k++;
+ t = t * random.nextDouble();
+ }
+ return k;
+ }
+
+ private void moveToNextElement(int num) {
--- End diff --
This method skip gap elements, you actually move to the next sampled
element in ```samplingProcess```, how about rename to ```skipGapElements```?
> Gap based random sample optimization
> ------------------------------------
>
> Key: FLINK-2533
> URL: https://issues.apache.org/jira/browse/FLINK-2533
> Project: Flink
> Issue Type: Improvement
> Components: Core
> Reporter: Chengxiang Li
> Priority: Minor
>
> For random sampler with fraction, like BernoulliSampler and PoissonSampler,
> Gap based random sampler could exploit O(k) sample implementation instead of
> previous O\(n\) sample implementation, it should perform better while sample
> fraction is very small. [This
> blog|http://erikerlandson.github.io/blog/2014/09/11/faster-random-samples-with-gap-sampling/]
> describes more detail about gap based random sampler.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)