Randseed

10 views
Skip to first unread message

Jody Crothers

unread,
May 18, 2023, 8:26:45 AM5/18/23
to TI-Innovator

Hi all,

I was wondering about the nitty gritty of how randseed and random numbers  works. 

Can we access the table of values that is used in some capacity?

Cheers
Jody

Sent from my Galaxy

John Hanna

unread,
May 18, 2023, 11:35:59 AM5/18/23
to ti-inn...@googlegroups.com
Long story short... Uses a linear function with special values mod something


--
You received this message because you are subscribed to the Google Groups "TI-Innovator for Education" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ti-innovator...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ti-innovator/SL2P216MB10486CFBBD54D12CBBC1FBB6B87F9%40SL2P216MB1048.KORP216.PROD.OUTLOOK.COM.

Fox, Peter

unread,
May 22, 2023, 1:12:20 AM5/22/23
to ti-inn...@googlegroups.com

Jody

 

What a random question. 😊

 

There are many random number generators ... way back in my University days we used one loosely titled “Long Seed Generator” which passed tests for randomness, but almost too well. The long seed generator required three seed values. From memory you needed six numbers in a row before you could identify what part of the sequence the generator was up to and therefore ‘reverse engineer’ the output and start predicting subsequent values. There are many different types of random generators available to choose from nowadays:

https://en.wikipedia.org/wiki/List_of_random_number_generators

 

From a pedagogical approach, (teaching students), it is worthwhile demonstrating the mid-square system (see below), it fails very quickly, but gives students and idea on how something can seem random, but its not.

Let’s say you ‘seed’ the generator with a two digit number: 37. Now you calculate 372 = 1369. You use the 100’s and 10’s digits as the new 2 digit number: 36.  Now 362  = 1296, again you use the 100’s and 10’s digits: 29.  Now 292 = 841 ... so the new number is 84. It’s not long before you realise this is a ridiculously poor system. However it provides a good prompt for students to design a better system. (Simple idea ... what if we used 3 digit numbers and used the 1000’s, 100’s and 10’s bits.) This at least gives students the notion of a formula that can generate random numbers, why we need a seed value and that ‘simple’ formulas lead to predictable outcomes, particularly if the formula is one to one. (nice concept to introduce). Of course the whole problem with having to seed random numbers is that it causes predictability, which is why some online random number generators are the best, they seed the generator using atomic clocks.

FYI – Gaming venues re-seed the random number generators frequently to avoid predictability!  

 

Once you’re done with random numbers, get students to explore Benford’s Law.

https://en.wikipedia.org/wiki/Benford%27s_law

It’s a lovely illustration of how using random numbers can cause problems! Consider Mr. Dodgy who decides to randomly generate lots of miscellaneous expenses for his income tax, Benford’s law will most likely catch Mr. Dodgy out!  There are also statistics tests you can use to detect whether something is actually random, humans are inherently bad at trying to create random numbers. If you ask your students to write down 20 random two digit numbers (allow repeats), chances are that most students will not use the same number twice however the odds of a repeat is actually quite high, and I would almost guarantee that none of the students would repeat a number three times, yet, in a class of 25 students, there is a very good chance that this will also happen.

 

Summary ... a lovely bundle of investigations and thoughts about this ‘random question’.  

 

Cheers

Peter

--

John Hanna

unread,
May 22, 2023, 6:32:39 AM5/22/23
to ti-inn...@googlegroups.com

Thanks, Peter,

This is the one I used to teach with my CS students:

    https://en.wikipedia.org/wiki/Linear_congruential_generator

 

Also, check this out:

    https://qrng.anu.edu.au/

 

  • John

kh7...@gmail.com

unread,
May 22, 2023, 9:43:07 AM5/22/23
to TI-Innovator for Education
Hopefully, Peter won't think of my follow up as just another random question.  :-)   So, here it goes:

Can we assume that TI-Nspire and TI 84 xxxx use the same algorithm despite differences in OS?
It seems that using the same seed number(s) results in the same "random numbers." 

Maybe, John, you can expand on your "long story short" answer. I actually had a teacher just ask me that question a few days ago.

Karlheinz

Fox, Peter

unread,
May 22, 2023, 8:37:02 PM5/22/23
to ti-inn...@googlegroups.com

Karlheinz

 

I think it is a reasonable assumption that TI-84 and TI-Nspire series use the same random number generator. Use the same seed value and generate random numbers on both devices and you get exactly the same values. 😊

John Hanna

unread,
May 23, 2023, 6:27:24 AM5/23/23
to ti-inn...@googlegroups.com

See my last post about ‘linear congruential generator’.

 

In a nutshell: xn+1 = (a*xn+c ) mod m

    where a, c and especially m are ‘special’ numbers.

     x0 = the seed

 

From: ti-inn...@googlegroups.com <ti-inn...@googlegroups.com> On Behalf Of kh7...@gmail.com
Sent: Monday, May 22, 2023 9:43 AM
To: TI-Innovator for Education <ti-inn...@googlegroups.com>

Subject: Re: Randseed

Hubert Langlotz

unread,
May 30, 2023, 12:10:24 PM5/30/23
to TI-Innovator
Hi,
some years ago we puplished the attached description, how the TI-Nspire rand() works.

For my students it was interesting to compare the L&S results with the results of rand().

Hubert Langlotz



randseed.pdf
Reply all
Reply to author
Forward
0 new messages