Hey Adhemar,A fine solution ineded!
I'm currently using a very similar
algorithm that also only needs to
read the whole file once. It's
interesting to see how comparison of
n random numbers yields equal chances
of P(i) = 1/n for every i from 0 to
n. This could be very useful, since
that algorithm I'm using requires a
modulo, a relatively expensive
operation, as well as a random number
for every line. I'll detail it in a
next blogpost, though.Emperical data
suggests the bias to be minimal,
which is to be expected looking at
the range of a random number (on my
platform GCC gives a RAND_MAX of
2147483647). Either way, the bias
could be an advantage for the problem
we want to solve.You don't happen to
have (a link to) a proof for this
algorithm (the equal chances part)?
Your comment spawned quite a
discussion about its correctness on
our IRC-channel .
http://jujjvhleo.com
[url=http://aqethunhs.com]aqethunhs[/
url]
[link=http://xgllps.com]xgllps[/link]
User:
Guest
Date: 2015-01-22
Hi, Im a freshman at Millikin
University and I am exaretmly
interested in acting in any short
film that would be the ideal fit for
me. Im a BA theatre Major.Please
contact me back if you have any
furtur questions, I hope to hear from
you soon.Thanks, Panda (Derrick)
Shenault