math::quasirandom(3tcl) Tcl Math Library math::quasirandom(3tcl)
______________________________________________________________________________
NAME
math::quasirandom - Quasi-random points for integration and Monte Carlo
type methods
SYNOPSIS
package require Tcl 8.5
package require TclOO
package require math::quasirandom 1
::math::quasirandom::qrpoint create NAME DIM ?ARGS?
gen next
gen set-start index
gen set-evaluations number
gen integral func minmax args
______________________________________________________________________________
DESCRIPTION
In many applications pseudo-random numbers and pseudo-random points in
a (limited) sample space play an important role. For instance in any
type of Monte Carlo simulation. Pseudo-random numbers, however, may be
too random and as a consequence a large number of data points is re-
quired to reduce the error or fluctuation in the results to the desired
value.
Quasi-random numbers can be used as an alternative: instead of "com-
pletely" arbitrary points, points are generated that are diverse enough
to cover the entire sample space in a more or less uniform way. As a
consequence convergence to the limit can be much faster, when such
quasi-random numbers are well-chosen.
The package defines a class "qrpoint" that creates a command to gener-
ate quasi-random points in 1, 2 or more dimensions. The command can ei-
ther generate separate points, so that they can be used in a user-de-
fined algorithm or use these points to calculate integrals of functions
defined over 1, 2 or more dimensions. It also holds several other com-
mon algorithms. (NOTE: these are not implemented yet)
One particular characteristic of the generators is that there are no
tuning parameters involved, which makes the use particularly simple.
COMMANDS
A quasi-random point generator is created using the qrpoint class:
::math::quasirandom::qrpoint create NAME DIM ?ARGS?
This command takes the following arguments:
string NAME
The name of the command to be created (alternatively: the
new subcommand will generate a unique name)
integer/string DIM
The number of dimensions or one of: "circle", "disk",
"sphere" or "ball"
strings ARGS
Zero or more key-value pairs. The supported options are:
o -start index: The index for the next point to be
generated (default: 1)
o -evaluations number: The number of evaluations to
be used by default (default: 100)
The points that are returned lie in the hyperblock [0,1[^n (n the num-
ber of dimensions) or on the unit circle, within the unit disk, on the
unit sphere or within the unit ball.
Each generator supports the following subcommands:
gen next
Return the coordinates of the next quasi-random point
gen set-start index
Reset the index for the next quasi-random point. This is useful
to control which list of points is returned. Returns the new or
the current value, if no value is given.
gen set-evaluations number
Reset the default number of evaluations in compound algorithms.
Note that the actual number is the smallest 4-fold larger or
equal to the given number. (The 4-fold plays a role in the de-
tailed integration routine.)
gen integral func minmax args
Calculate the integral of the given function over the block (or
the circle, sphere etc.)
string func
The name of the function to be integrated
list minmax
List of pairs of minimum and maximum coordinates. This
can be used to map the quasi-random coordinates to the
desired hyper-block.
If the space is a circle, disk etc. then this argument
should be a single value, the radius. The circle, disk,
etc. is centred at the origin. If this is not what is re-
quired, then a coordinate transformation should be made
within the function.
strings args
Zero or more key-value pairs. The following options are
supported:
o -evaluations number: The number of evaluations to
be used. If not specified use the default of the
generator object.
TODO
Implement other algorithms and variants
Implement more unit tests.
Comparison to pseudo-random numbers for integration.
REFERENCES
Various algorithms exist for generating quasi-random numbers. The gen-
erators created in this package are based on: http://extremelearn-
ing.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
KEYWORDS
mathematics, quasi-random
CATEGORY
Mathematics
tcllib 1 math::quasirandom(3tcl)