Post Reply 
A Random Question
06-10-2017, 01:45 AM
Post: #5
RE: A Random Question
(06-10-2017 12:03 AM)Joe Horn Wrote:  My strong gut feeling is that using MANT on random X's is a Bad Thing, because it SEEMS like it simply multiplies X by 10, but that's only if X>=0.1, which it isn't 10% of the time. And 1% of the time X<0.01, which is even worse. And 0.1% of the time X<0.001, et cetera. In effect, MANT(X) where X=RAND returns X*10^(-XPON(X)). This will not return uniformly random numbers at all.

@Joe, you've identified where my attempt to translate what I'm testing into a UserRPL equivalent failed miserably. I agree with your assessment, MANT is a bad idea due to the issues you mention.

I'll attempt to give a better/more detailed description of my actual approach:

- A call to (SysRPL) %RAN is issued so that a new RNSEED is created. The result is dropped from the stack as it won't be used; it's the internal seed that I need.
- A Saturn routine is passed a BINT parameter that represents the range of the random number desired.
- The Saturn routine makes a local copy of the 12 digits stored at RNSEED+3 (which are in decimal form) and converts them to hex form.
- The converted RNSEED is then divided by the BINT passed as a parameter; the remainder of this division becomes the zero-based form of the result.
- 1 is added to make the result 1-based.

If you've followed the above, you can see that the pitfall you identified doesn't come into play here. The decimal form of RNSEED contains leading zeros (it isn't normalized), so the magnitude of the seed is maintained appropriately.

The specific application I have in mind is for use in a "shuffle" command to be included in a library of extended list processing utilities. In this case, the range of the expected result would be limited to whatever size list is being shuffled. Realistically, probably no more than 3000. Processing larger lists on the 50g isn't very practical due to memory and performance issues. Garbage collection rears its ugly head pretty quickly when exploding/imploding lists that large.

@Pauli:

Given the more detailed description (and scope), does this change your assessment of the risk of bias?

@anyone:

My intent with this is simply to retain as much of the "quality" of RAND as I can for the purpose of randomizing a list of items that's probably no larger than 2-3 thousand items. Does using the RNSEED as I have described above create a significant bias?
Find all posts by this user
Quote this message in a reply
Post Reply 


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)