HP Forums
Can we use magic squares as random number generators? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Can we use magic squares as random number generators? (/thread-14308.html)



Can we use magic squares as random number generators? - Namir - 01-03-2020 09:48 PM

Hi All,

I ran into magic squares (Matlab has a magic() built in function) and a curiosity light bulb went on in my bain, askin the following question:

"Can we use (large) magic squares to generate random numbers?"

I did a limit test (100 by 100 magic square matrix) and then manipulated the numbers:

1. Divide each element by the row/colum sum.
2. Discard the first few decimal digits using something like:

x = 100*x - fix(100*x) = frac(100*x)

I got 10,000 random numbers which may not be a whole lot of PC applications.

Any better approach to generate (and re-generate) batches of random numbers from magic squares?

Namir


RE: Can we use magic squares as random number generators? - aamiel - 01-06-2020 09:14 AM

Namir,

If you have a good random number generator to create your magic square and use the right method, it could work. Otherwise, I would be very worried. (See there).


RE: Can we use magic squares as random number generators? - lrdheat - 01-06-2020 03:24 PM

Made me think back to when I wanted to generate a series of random numbers back in 1977 with my HP-67 (have no idea how I was separated away from that beautifully done device). In radian mode, I took the sine of a seed number (incremented up by 1 for each new random number), and did away with the first 6 digits with my program. Seemed fine for my needs (was simulating baseball games for a simulated season!)


RE: Can we use magic squares as random number generators? - Namir - 01-07-2020 01:07 PM

(01-06-2020 03:24 PM)lrdheat Wrote:  Made me think back to when I wanted to generate a series of random numbers back in 1977 with my HP-67 (have no idea how I was separated away from that beautifully done device). In radian mode, I took the sine of a seed number (incremented up by 1 for each new random number), and did away with the first 6 digits with my program. Seemed fine for my needs (was simulating baseball games for a simulated season!)

Discarding the first few digits after the decimal seems to work fine in general, because the digits that remain are more or less noise! I was able to develop a Matlab random number generator (luck had something to do with it). But once I ported it to Excel VBA the random generator did not give very good results. My conclusion is that the software's basic math oprations and functions have something to do with it.