How to teach random number generator algorithms?

How can I teach random number generator algorithms? I'd like to show how seeding makes randomization closer to truly random.

Details of the task to be given are as follows:

Code should read a text file. The file has random words (one word on each line). This is the dataset from which words will be selected randomly.

I am unsure of how to explain the difference between deterministic randomization and non-deterministic randomization using the above example.

migrated from cseducators.stackexchange.comJun 23 '17 at 19:40

This question came from our site for those involved in the field of teaching Computer Science.

• Welcome to Computer Stack Exchange! Could you add some context to your question? What is the level of the students? Also, what do you mean by strong in "makes randomization more strong"? – Itamar Green Jun 23 '17 at 6:04
• I've voted to close this as too broad becuase there are so many different ways to teach randomization and so there are too many "right" answers – thesecretmaster Jun 23 '17 at 10:36
• This question is rather too close to 'please teach me the material I'm required to cover' rather than asking about how to approach teaching this material. It could be interesting if edited though. – Sean Houlihane Jun 23 '17 at 12:45
• @BenI. We should be wary this doesn't become a running theme for example — folks asking "how or why <something> works" by tacking on "how to teach..." to the front of it. There's nothing inherently wrong with the question itself, but these questions should be redirected (like you said) and closed to preserve the focus and audience of this specialized site. – Robert Cartaino Jun 23 '17 at 18:26
• @RobertCartaino Agreed. This question does not appear to belong here. – Ben I. Jun 23 '17 at 19:25

So much depends on the language or library you are using. If the tool you are using allows feeding a specific seed I would start by demonstrating how using the same seed gives the same set of random numbers each time. If not and the tool uses the system time as the seed, as many do, then create several random data sets if a very tight look and show how they are the same.

This cre3ating several random sets in a tight loop is something students often do by accident BTW. It gives them no end of trouble as they see identical numbers for all of them.

Then demonstrate how the same code gives different (from the first example) random numbers when used with a different seed.

With your example, using a random number from the same seed would return the same word every time. Using a time based seed should normally return a different word each time.

BTW random.org is a useful/interesting site on the topic. They go into some detail on random and pseudo-random numbers at https://www.random.org/randomness/

• If your pseudo number generator is producing the same sequences for different seeds, then you need a new one. This should not happen. If your seed is 32bit then getting the same sequence by luck would take a long time, but could be done. However to find a match would take a lot of memory, or the use of hashes. Just checking the first few bytes may not prove much. Ensure that you do the stats correct. You should expect the first 4 bytes to match approximately 1 in 4 billion times. If you saw this once with only 4 billion trials it would be statistically in significant. … – ctrl-alt-delor Jun 24 '17 at 15:59