Randomization and Arrays

This page is all about randomization routines and array shuffling. View source to read the extensive comments in the JavaScript code regarding these procedures.

Each time you click "Shuffle Array", you will randomly rearrange the image objects in the imageArray which I have created. When you then click on the links to display the images stored in the various positions of imageArray, you can see, via the switching image below, how the images have indeed been randomly, and non-repetitively, shuffled.

You may also shuffle the array using two alternative methods, Inefficient and Brute Force. View source for details.

The Tests for Floor vs. Rounding randomization procedures depict the spread of numbers between 1 and 6 that are selected in 10,000 random number generations. Note that the Floor method produces the more level spread, whereas the rounding method favors the middle numbers at the expense of the ends. 0 and 7 have been included in the test to prove that neither randomization procedure generates numbers outside of our chosen boundaries. Again, view source for more details.

Test Floor Randomization Routine
Test Rounding Randomization Routine
Shuffle Array
Shuffle Array using Inefficient Method
Shuffle Array using Brute Force Method (not recommended)
Display Image from Position 0 of imageArray
Display Image from Position 1 of imageArray
Display Image from Position 2 of imageArray
Display Image from Position 3 of imageArray
Display Image from Position 4 of imageArray
Display Image from Position 5 of imageArray