Exact Discrete pseudo-Random Sampling
|
04-08-2020, 11:57 PM
Post: #6
|
|||
|
|||
RE: Exact Discrete pseudo-Random Sampling
(04-08-2020 05:42 AM)Paul Dale Wrote: Don't reinvent the wheel. Look up Lemire's delightful: Fast Random Integer Generation in an Interval. Amazingly, Lemire's sample rejection trick work in any base. Example, say random r = [0, 10), but we wanted random range [0, 7), without bias. Code: r 0 1 2 3 4 5 6 7 8 9 m=10, s=7 Note: we could also reject high cases (sr%m = 7,8,9), and still remove the bias. Now, try the same, but with random r = [0, 12) Code: r 0 1 2 3 4 5 6 7 8 9 10 11 m=12, s=7 Again, reject high cases (sr%m = 7,8,9,10,11) also remove the bias. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Exact Discrete pseudo-Random Sampling - ttw - 04-08-2020, 03:33 AM
RE: Exact Discrete pseudo-Random Sampling - Paul Dale - 04-08-2020, 05:42 AM
RE: Exact Discrete pseudo-Random Sampling - Albert Chan - 04-08-2020, 08:56 PM
RE: Exact Discrete pseudo-Random Sampling - Albert Chan - 04-08-2020 11:57 PM
RE: Exact Discrete pseudo-Random Sampling - ijabbott - 04-09-2020, 12:54 AM
RE: Exact Discrete pseudo-Random Sampling - Paul Dale - 04-09-2020, 04:53 AM
RE: Exact Discrete pseudo-Random Sampling - Albert Chan - 04-08-2020, 12:34 PM
RE: Exact Discrete pseudo-Random Sampling - ttw - 04-08-2020, 12:53 PM
|
User(s) browsing this thread: 4 Guest(s)