Lovegrove Mathematicals

logo

"Dedicated to making Likelinesses the entity of prime interest"

Randomisation

Several of the algorithms on this website require a distribution to be randomised from A to B, where 1≤A<B≤N. This is achieved in the following way.

Let F be a distribution which is to be randomised from A to B.

Declare a real variable RA and populate RA(A), ..., RA(B) with random numbers

By means of a sequence of transpositions, arrange RA(A), ..., R(B) into descending order
The fact that RA(A), ..., RA(B) is sorted into descending, rather than ascending, order is neither here nor there

Whenever a transposition is applied to RA, apply it also to F.

The result is that F(A), ..., F(B) will be sorted into random order.