Skip to content

Commit

Permalink
LiLSampling excludes 0 from random and generates in (0,1)
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Jul 2, 2018
1 parent dab22d3 commit 095be15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/gr/james/sampling/LiLSampling.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ void init(int sampleSize, Random random) {

@Override
long skipLength(long streamSize, int sampleSize, Random random) {
final long skip = (long) (Math.log(random.nextDouble()) / Math.log(1 - W));
W = W * Math.exp(Math.log(random.nextDouble()) / sampleSize);
final double random1 = RandomSamplingUtils.randomExclusive(random);
final double random2 = RandomSamplingUtils.randomExclusive(random);
final long skip = (long) (Math.log(random1) / Math.log(1 - W));
W = W * Math.exp(Math.log(random2) / sampleSize);
return skip;
}
}

0 comments on commit 095be15

Please sign in to comment.