Re:Vitter's reservoir sampling algorithm D: randomly selecti...
by chipsambos on Monday April 04, 2016 @07:08AM
(#11420862)
var naming aside, the whitespacing is perplexing:
U = random_double(); negSreal=-S;
y1=exp(log(U*Nreal/qu1real)*nmin1inv);
Vprime = y1 * (-X/Nreal+1.0)*(qu1real/(negSreal+qu1real));
if(Vprime <= 1.0) break; y2=1.0; top = -1.0+Nreal; if(-1+n > S){bottom=-nreal+Nreal;limit=-S+N;}
else{bottom=-1.0+negSreal+Nreal; limit=qu1;}
Sometimes two statements per line, sometimes one. Sometimes spaces before and after equals, sometimes none. Sometimes multiple ifs, breaks and statements on one line.It looks like it was copy-pasted from a pdf. Maybe it was.
Re:Vitter's reservoir sampling algorithm D: randomly selecti...
by retbull on Monday April 04, 2016 @01:37PM
(#11423737)
I feel like 2 seconds in an ide would have saved readability quite a bit. A simple automated cleanup would have helped worlds.
Re:Vitter's reservoir sampling algorithm D: randomly selecti...
by wodenokoto on Monday April 04, 2016 @03:43AM
(#11420079)
On the other hand, you need the original names in order to reference back to the paper.
Nonetheless, I find this coding style unreadable. "Y" is not a very good name for an exponentially distributed random variate, especially in a function that defines 24 variables with mostly meaningless names. :-(