Post Reply 
(50g) Programme to Produce a Cryptologically Interesting Random Bit
07-22-2023, 11:56 PM
Post: #6
RE: (50g) Programme to Produce a Cryptologically Interesting Random Bit
(07-22-2023 09:04 AM)Gerald H Wrote:  After some testing the programme in posting #1 has an average value nearer to 0.5 than that of posting #2 - Could some erudite individual venture a reason for different average values?

I'm not qualified to answer your specific question as posted, but I am definitely aware that it is easy to introduce bias in PRNGs when applying digit manipulations to the results. I suspect there's a bias resulting from the method used in your second program, though it's not clear to me where it's coming from.

Of course you could simply test the RAND value as being > or < 0.5, but that is a rather blunt force method which disregards the "randomness" of the trailing digits to give its result.

If you want all of the RAND digits to have some influence in the output, something like this might work:
Code:
::
   CK0NOLASTWD          ( no arguments expected )
   %RAN                 ( next RAND result )
   OCRC SWAPDROP        ( obtain the user binary CRC of the RAND result )
   HXS>#                ( convert the CRC to a system binary number )
   ONE #AND             ( isolate the least significant bit from the CRC )
   UNCOERCE             ( map #0 or #1 to %0 or %1 )
;

I'm not an expert in PRNGs, so I won't guarantee that there's no bias in the above method. In fact, I suspect it's likely that there is some bias due to the checksum always including the same prologue data for each RAND result. That said, the averages for each block of 1 million I tested still seemed reasonable:
0.499529
0.499503
0.500005
0.500317
0.500096
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (50g) Programme to Produce a Cryptologically Interesting Random Bit - DavidM - 07-22-2023 11:56 PM



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