in reply to Re^2: A Random Fortune Cookie (updated)
in thread A Random Fortune Cookie

You’re a *much* better mathematician than I. It’s from the Camel, 8.6. Picking a Random Line from a File. I can’t screenshot it or cut and paste it either because the text contains math images. The trick lies in reselecting lines as it goes and the odds of selection being “fair” across the entire file. As you say, one line is guaranteed to be picked. As subsequent lines are scanned, the odds of choosing them, and replacing the original selection, become proportionate to how many lines have been read.

Update: didn’t see your update before I stubmitted. :P

Replies are listed 'Best First'.
Re^4: A Random Fortune Cookie
by LanX (Saint) on Mar 10, 2021 at 17:53 UTC