good answer by sumitra narayan
Algorithm R from wikipedia:
(* S has items to sample, R will contain the result *)
ReservoirSample(S[1..n], R[1..k])
// fill the reservoir array
for i = 1 to k
R[i] := S[i]
// replace elements with gradually decreasing probability
for i = k+1 to n
j := random(1, i) // important: inclusive range
if j <= k R[j] := S[i]
(* S has items to sample, R will contain the result *)
ReservoirSample(S[1..n], R[1..k])
// fill the reservoir array
for i = 1 to k
R[i] := S[i]
// replace elements with gradually decreasing probability
for i = k+1 to n
j := random(1, i) // important: inclusive range
if j <= k R[j] := S[i]
1 comment:
Did you realize there's a 12 word sentence you can tell your man... that will induce deep feelings of love and instinctual attraction for you deep inside his heart?
That's because hidden in these 12 words is a "secret signal" that triggers a man's impulse to love, worship and guard you with all his heart...
====> 12 Words That Trigger A Man's Love Response
This impulse is so built-in to a man's mind that it will drive him to work harder than before to make your relationship the best part of both of your lives.
Matter of fact, fueling this mighty impulse is so binding to getting the best ever relationship with your man that once you send your man one of the "Secret Signals"...
...You will instantly find him open his mind and heart for you in such a way he never expressed before and he'll see you as the only woman in the world who has ever truly attracted him.
Post a Comment