online toss

Web authors use several programming languages. One of the more flexible is Javascript. In the grammar of Javascript are many commands, called functions—indicated by "( )".

The function we need to toss a coin is ready-made: "math.random( )". According to the standard-setters for Javascript—the European Computer Manufacturers' Association:

Math.random( ) returns a Number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
This function takes no arguments.

more


Hmmm...

‟chosen randomly or pseudo randomly”

...this looks like a fudge.

What the folk at ECMA are saying here is: to construct a random sequence is a contradiction in terms. The sequence of numbers constructed by Math.random( ) will in fact recur, but so far ahead that we need not be concerned. Try this technical explanation, ‛The Coin of Tyche’.
more


To toss a coin with an even chance of heads, value 3, or tails, 2, we write something like:

function tossCoin( ) {
  var coin = Math.random( );
    if ( coin < 0.5 )   return 2;   else return 3;   }

OK, coinToss—
we need to manipulate math.random( )—technically speaking, we need to give it an 'argument'.
But math.random( ) brooks no argument, so we'll give it an alias—'var' (for 'variable')—and call the alias 'coin'.
Now:
if 'coin', when tossed, is less than 0.5, give us a 2;
if it's equal to or more than 0.5, make it a 3.
Easy.


All online versions of the I Ching use some implementation of "math.random( )" or its equivalent in other languages. From the archive...

https://archive.org/details/msdos_I_CHING_shareware
https://archive.org/details/Big_Red_398_I_Ching
https://archive.org/details/603_Anthology_Poole_Pilot_-I_Ching_Diskcat

top