Tcl Library Source Code

Bounty program for improvements to Tcl and certain Tcl packages.

[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


math::quasirandom - Quasi-random points for integration and Monte Carlo type methods

Table Of Contents


package require Tcl 8.6
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


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 required to reduce the error or fluctuation in the results to the desired value.

Quasi-random numbers can be used as an alternative: instead of "completely" 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 generate quasi-random points in 1, 2 or more dimensions. The command can either generate separate points, so that they can be used in a user-defined algorithm or use these points to calculate integrals of functions defined over 1, 2 or more dimensions. It also holds several other common 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.


A quasi-random point generator is created using the qrpoint class:

The points that are returned lie in the hyperblock [0,1[^n (n the number 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:


Implement other algorithms and variants

Implement more unit tests.

Comparison to pseudo-random numbers for integration.


Various algorithms exist for generating quasi-random numbers. The generators created in this package are based on:


mathematics, quasi-random