Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

6 Random elements
 6.1 Randomizing mutable objects
 6.2 Product replacement

6 Random elements

In this chapter we describe some fundamental mechanisms to produce (pseudo-) random elements that are used later in Chapter 7 about searching in groups and orbits.

6.1 Randomizing mutable objects

For certain types of mutable objects one can get a random one by calling the following operation:

6.1-1 Randomize
‣ Randomize( ob[, rs] )( operation )

Returns: nothing

The mutable object ob is changed in place. The value afterwards is random. The optional second argument rs must be a random source and the random numbers used to randomize ob are created using the random source rs (see Reference: Random Sources). If rs is not given, then the global GAP random number generator is used.

Currently, there are Randomize methods for compressed vectors and compressed matrices over finite fields. See also the cvec package for methods for cvecs and cmats.

For vectors and one-dimensional subspaces there are two special functions to create a list of random objects:

6.1-2 MakeRandomVectors
‣ MakeRandomVectors( sample, number[, rs] )( function )

Returns: a list of random vectors

sample must be a vector for the mutable copies of which Randomize (6.1-1) is applicable and number must be a positive integer. If given, rs must be a random source. This function creates a list of number random vectors with the same type as sample using Randomize (6.1-1). For the creation of random numbers the random source rs is used or, if not given, the global GAP random number generator.

6.1-3 MakeRandomLines
‣ MakeRandomLines( sample, number[, rs] )( function )

Returns: a list of normalised random vectors

sample must be a vector for the mutable copies of which Randomize (6.1-1) is applicable and number must be a positive integer. If given, rs must be a random source. This function creates a list of number normalised random vectors with the same type as sample using Randomize (6.1-1). Normalised here means that the first non-zero entry in the vector is equal to \(1\). For the creation of random numbers the random source rs is used or, if not given, the global GAP random number generator.

6.2 Product replacement

For computations in finite groups product replacement algorithms are a viable method of generating pseudo-random elements. This section describes a framework and an object type to provide these algorithms. Roughly speaking a product replacer object is something that is created with a list of group generators and produces a sequence of pseudo random group elements using some random source for random numbers.

6.2-1 ProductReplacer
‣ ProductReplacer( gens[, opt] )( operation )

Returns: a new product replacer object

gens must be a list of group generators. If given, opt is a GAP record with options. The operation creates a new product replacer object producing pseudo random elements in the group generated by the generators gens.

The exact algorithm used is explained below after the description of the options.

The following components in the options record have a defined meaning:

randomsource

A random source object that is used to generate the random numbers used. If none is specified the global GAP random number generator is used.

scramble

The scramble value in the algorithm described below can be set using this option. The default value is \(30\).

scramblefactor

The scramblefactor value in the algorithm described below can be set using this option. The default value is \(4\).

addslots

The addslots value in the algorithm described below can be set using this option. The default value is \(5\).

maxdepth

If maxdepth is set, then the production of pseudo random elements starts all over whenever maxdepth product replacements have been performed. The rationale behind this is that the elements created should be evenly distributed but that the expressions in the generators should not be too long. A good compromise is usually to set maxdepth to \(300\) or \(400\).

noaccu

Without this option set to true the rattle version of product replacement is used which involves an accumulator and uses two or three products per random element. To use the shake version with only one or two product replacement per random element set this component to true. The exact number of multiplications per random element also depends on the value of the accelerator component.

normalin

There is a variant of the product replacement algorithm that produces elements in the normal closure of the group generated by a list of elements. It needs random elements in the ambient group in which the normal closure is defined. This is implemented here by setting the normalin component to a product replacer object working in the ambient group. In every step two elements \(a\) and \(b\) are picked and then \(a\) is either replaced by \(a*b^c\) or \(b^c*a\) (with equal probability), where \(c\) is a random element from the ambient group produced by the product replacer in the normalin component. It is recommended to switch off the accumulator and accelerator in the product replacer object for the ambient group. Then to produce one random element in the normal closure needs four multiplications.

accelerator

If this option is set to true (which is the default), then the accelerator is used. This means that in each step two product replacement steps are performed, where both involve one distinguished slot called the captain. The idea is that the current team of random elements uses one amongst them more often to increase the length of the words produced. See below for details of the algorithm with and without accelerator.

retirecaptain

If this component is bound to a positive integer then the captain retires after so many steps of the algorithm. This is to use only two multiplications for each random element in the long run after proper mixing. The default value for retirecaptain is twice the scrambling time.

accus

This component (default is 5) is the number of accumulators to use in the rattle variant. All accus are used in a round robin fashion. The purpose of multiple accus is to have a greater stochastical independence of adjacent random elements in the sequence.

The algorithm used does the following: A list of Length(gens)+addslots elements is created that starts with the elements gens and is filled up with random generators from gens. This element is called the team. A product replacement without accelerator randomly chooses two elements in the list and replaces one of them by the product of the two. If an accelerator is used, then one product replacement step randomly chooses two slots \(i\) and \(j\) where \(i,j > 1\) but \(i=j\) is possible. Then first \(l[1]\) is replaced by \(l[1]*l[i]\) and after that \(l[j]\) is replaced by \(l[j]*l[1]\). The first team member is called the captain, so the captain is involved in every product replacement.

One step in the algorithm is to do one product replacement followed by post-multiplying the result to the accumulator if one (or more) is used. Multiple accus (see the accus component) are used in a round robin fashion.

First Maximum(Length(gens)*scramblefactor,scramble) steps are performed. After this initialisation for every random element requested one step is done and the resulting element returned.

6.2-2 Next
‣ Next( pr )( operation )

Returns: a (pseudo-) random group element g

pr must be a product replacer object. This operation makes the object generate the next random element and return it.

6.2-3 Reset
‣ Reset( pr )( operation )

Returns: nothing

pr must be a product replacer object. This operation resets the object in the sense that it resets the product replacement back to the state it had after scrambling. Note that since the random source is not reset, the product replacer object will return another sequence of random elements than before.

6.2-4 AddGeneratorToProductReplacer
‣ AddGeneratorToProductReplacer( pr, el )( operation )

Returns: nothing

pr must be a product replacer object. This operation adds the new generator el to the product replacer without needing a completely new initialisation phase. From after this call on the product replacer will generate random elements in the group generated by the old generators and the new element el.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 Bib Ind

generated by GAPDoc2HTML