A Random Question
06-09-2017, 11:37 PM (This post was last modified: 06-10-2017 11:50 PM by Paul Dale.)
Post: #3
 Paul Dale Senior Member Posts: 1,748 Joined: Dec 2013
RE: A Random Question
Both of these will be biassed. Which one is closer to uniform will depend on <num>.

Off the top of my head, something like this would be better:

Code:
<< 1E11 -> n l      <<         l n IQUOT n *         # Largest value below which the roll is fair         DO RAND l * IP        # Roll once         UNTIL DUP2 < END      # Check within range for fair roll         NIP n MOD 1 +         # Clean up the stack and produce the result     >> >>

I've not checked this code, so there are likely errors.

I've fixed the point David noted below (IQUOT instead of IDIV).

Pauli
 « Next Oldest | Next Newest »

 Messages In This Thread A Random Question - DavidM - 06-09-2017, 03:15 PM RE: A Random Question - pier4r - 06-09-2017, 03:46 PM RE: A Random Question - Paul Dale - 06-09-2017 11:37 PM RE: A Random Question - Joe Horn - 06-10-2017, 12:03 AM RE: A Random Question - DavidM - 06-10-2017, 01:45 AM RE: A Random Question - pier4r - 06-10-2017, 08:55 AM RE: A Random Question - DavidM - 06-10-2017, 05:10 PM RE: A Random Question - Paul Dale - 06-10-2017, 05:18 AM RE: A Random Question - John Keith - 06-10-2017, 12:57 PM RE: A Random Question - pier4r - 06-10-2017, 01:20 PM RE: A Random Question - DavidM - 06-10-2017, 03:51 PM RE: A Random Question - Paul Dale - 06-10-2017, 11:49 PM RE: A Random Question - DavidM - 06-11-2017, 01:11 AM RE: A Random Question - Paul Dale - 06-11-2017, 05:04 AM RE: A Random Question - lrdheat - 06-10-2017, 02:28 PM RE: A Random Question - Paul Dale - 06-11-2017, 12:00 AM RE: A Random Question - ttw - 06-11-2017, 12:21 AM RE: A Random Question - DavidM - 06-11-2017, 01:39 AM RE: A Random Question - Paul Dale - 06-11-2017, 05:19 AM RE: A Random Question - ttw - 06-13-2017, 06:13 AM RE: A Random Question - Paul Dale - 06-11-2017, 12:38 AM

User(s) browsing this thread: 1 Guest(s)