# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I was browsing in the old HP-41C program library and I found this link for "Random Number Generators for the HP-41" by Jean-Marc Baillard. This link points out to five PRNGs (the first four are more serious). The first four HP-1C programs seem very usable. Has anyone used these PRNGs? Your take on these algorithms?

Namir
Just looking quickly leads me to guess that program #2 is best. Which number to use for the multiplier depends on the continued fraction expansion of that multiplier and 9,999,999,967. One with smaller partial quotients will generally be better.

Program #1 isn't too bad; the multiplier (9821 in this case) seems designed to give the longest period modulo a power of 10. Again, one should choose a pair with a continued fraction expansion with small partial quotients.
Note that though it references the well-known formula xn+1 = FRC ( 9821 xn + 0.211327 ), his program 1 is actually xn+1 = FRC ( 9^8 xn + 0.236067977 ).

Programs 1 and 2 both sound interesting. As Jean-Marc's post is 13 years old, I wonder if anyone has tested these RNG's using Knuth's spectral test or other methods?

John
(02-26-2017 03:17 PM)John Keith Wrote: [ -> ]Programs 1 and 2 both sound interesting. As Jean-Marc's post is 13 years old, I wonder if anyone has tested these RNG's using Knuth's spectral test or other methods?

Here's the current link to his own web site, likely to be more current that the one in the forum:

http://hp41programs.yolasite.com/alea.php
(02-26-2017 03:23 PM)Ángel Martin Wrote: [ -> ]
(02-26-2017 03:17 PM)John Keith Wrote: [ -> ]Programs 1 and 2 both sound interesting. As Jean-Marc's post is 13 years old, I wonder if anyone has tested these RNG's using Knuth's spectral test or other methods?

Here's the current link to his own web site, likely to be more current that the one in the forum:

http://hp41programs.yolasite.com/alea.php

Jean-Marc's site has mainly put the same information in a nicer and colored format. I did not see any significant change. Still good code in my book!!

Namir
There has been a lot of work in PRNGs in the last decade or so.

Many older PRNGs, particularly the simpler ones, are no longer considered adequate for many purposes, despite the fact that they pass the spectral test.

While there are many prominent researchers in this area, I have appreciated the work done by George Marsaglia. See the Wikipedia page for more information.
(03-03-2017 01:18 AM)Chris Hanson Wrote: [ -> ]There has been a lot of work in PRNGs in the last decade or so.

Many older PRNGs, particularly the simpler ones, are no longer considered adequate for many purposes, despite the fact that they pass the spectral test.

While there are many prominent researchers in this area, I have appreciated the work done by George Marsaglia. See the Wikipedia page for more information.

I do make a big distinction between simpler PRNGs for calculators and PRNGs for computer aplications. The two PRNGs belong in two different classes. The PRNGs by J.M Bailliard belong to vintage calculators and, in most likelihood, will not provide high-standard randomness for computer applications. Nevertheless, calculator PRNGs provide adequate random numbers for calculator games and simulations where the total number of random number generated is relatively small, compared to computer applications.
(03-03-2017 05:56 AM)Namir Wrote: [ -> ]I do make a big distinction between simpler PRNGs for calculators and PRNGs for computer aplications. The two PRNGs belong in two different classes. The PRNGs by J.M Bailliard belong to vintage calculators and, in most likelihood, will not provide high-standard randomness for computer applications. Nevertheless, calculator PRNGs provide adequate random numbers for calculator games and simulations where the total number of random number generated is relatively small, compared to computer applications.

Complete agreement.

On the CX of course the dilemma is non-existing: TIME does the randomness for you...
The 34S has a reasonably modern Tausworthe generator. I'd have liked to have included a Mersenne twister based RAND but there wasn't enough RAM for it. Neither of these is up to cryptographic standards but they are decent enough for other purposes.

Pauli
(03-03-2017 08:09 AM)Paul Dale Wrote: [ -> ]The 34S has a reasonably modern Tausworthe generator. I'd have liked to have included a Mersenne twister based RAND but there wasn't enough RAM for it. Neither of these is up to cryptographic standards but they are decent enough for other purposes.

Pauli

Pauli,

I agree that the 34S has the best PRNG. The WP-42S is in a class apart.

Namir
The microcontroller inside the dm42/wp43 does have a true random number generator inside it. We are at the threshold of a new kind of "randomness" in our machines.
(03-03-2017 11:01 PM)Namir Wrote: [ -> ]...
I agree that the 34S has the best PRNG. The WP-24S is in a class apart.
...

I've never seen a WP-24S. I'm guessing this was a WP-34S instead?

(Post 55)
(03-04-2017 12:10 AM)emece67 Wrote: [ -> ]The microcontroller inside the dm42/wp43 does have a true random number generator inside it. We are at the threshold of a new kind of "randomness" in our machines.

I'm actually be a bit sceptical of TRNGs in hardware -- I've seen more than a few that were biassed and that needed software assistance to produce good random output. Of course this fix is entirely possible in the dm42/wp34. I'd be more than able to implement a NIST SP 800-90b compliant RNG.

- Pauli
(03-04-2017 03:06 AM)brickviking Wrote: [ -> ]
(03-03-2017 11:01 PM)Namir Wrote: [ -> ]...
I agree that the 34S has the best PRNG. The WP-24S is in a class apart.
...

I've never seen a WP-24S. I'm guessing this was a WP-34S instead?

(Post 55)

I do have my own unique version of the WP-24S ... I just took an existing WP-34S and relabeled it WP-24S ... :-)

Namir
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :