monte carlo

Simulations

Overview


Javascript provides a function for generating a random number between 0 and 1.


let test = Math.random();
					

Seeding


For many applications this is sufficient. However, for production quality code, this is often insufficient. This is because you cannot seed the function. Seeding is a process whereby you pass a number to the generator, and this fixes the future outcomes to a given stream. This may seem counter intuitive, because the point of the generator is to be random. However, the resulting stream of numbers, while fixed, for all intents and purposes still looks and functions like a random sequence. But because it is fixed, when we run tests against our code, we can more easily identify bugs.

A good example of a random genearator that can be seeded is provided by David Bau and is hosted here.

Contents