LowDiscrepancySequence

class LowDiscrepancySequence(*args)

Base class to generate low discrepancy sequences.

Available constructors:

LowDiscrepancySequence(dimension=1)

Parameters
dimensionint

Dimension of the points of the low discrepancy sequence.

Notes

The low discrepancy sequences, also called ‘quasi-random’ sequences, are a deterministic alternative to random sequences for use in Monte Carlo methods. These sequences are sets of equidistributed points which the error in uniformity is measured by its discrepancy.

The discrepancy of a set P = \{x_1, \hdots, x_N\} is defined, using Niederreiter’s notation, as:

D_N(P) = \sup_{B\in J} \left| \frac{A(B;P)}{N} - \lambda_s(B) \right|

where \lambda_s is the s-dimensional Lebesgue measure, A(B;P) is the number of points in P that fall into B, and J is the set of s-dimensional intervals or boxes of the form:

\prod_{i=1}^s [a_i, b_i) = \{ \mathbf{x} \in \mathbf{R}^s : a_i \le x_i < b_i \} \,

where 0 \le a_i < b_i \le 1.

The star-discrepancy D_N^*(P) is defined similarly, except that the supremum is taken over the set J^* of intervals of the form:

\prod_{i=1}^s [0, u_i)

where u_i is in the half-open interval [0, 1).

A low-discrepancy sequence can be generated only through the derived classes of LowDiscrepancySequence. The sequences implemented are Faure, Halton, Reverse Halton, Haselgrove and Sobol sequences.

Examples

>>> import openturns as ot
>>> # Create a sequence of 3 points of 2 dimensions
>>> sequence = ot.LowDiscrepancySequence(ot.SobolSequence(2))
>>> print(sequence.generate(3))
0 : [ 0.5  0.5  ]
1 : [ 0.75 0.25 ]
2 : [ 0.25 0.75 ]

Methods

computeStarDiscrepancy(self, sample)

Compute the star discrepancy of a sample uniformly distributed over [0, 1).

generate(self, \*args)

Generate a sample of pseudo-random vectors of numbers uniformly distributed over [0, 1).

getClassName(self)

Accessor to the object’s name.

getDimension(self)

Accessor to the dimension of the points of the low discrepancy sequence.

getId(self)

Accessor to the object’s id.

getImplementation(self, \*args)

Accessor to the underlying implementation.

getName(self)

Accessor to the object’s name.

initialize(self, dimension)

Initialize the sequence.

setName(self, name)

Accessor to the object’s name.

__init__(self, *args)

Initialize self. See help(type(self)) for accurate signature.

computeStarDiscrepancy(self, sample)

Compute the star discrepancy of a sample uniformly distributed over [0, 1).

Parameters
sample2-d sequence of float
Returns
starDiscrepancyfloat

Star discrepancy of a sample uniformly distributed over [0, 1).

Examples

>>> import openturns as ot
>>> # Create a sequence of 3 points of 2 dimensions
>>> sequence = ot.LowDiscrepancySequence(ot.SobolSequence(2))
>>> sample = sequence.generate(16)
>>> print(sequence.computeStarDiscrepancy(sample))
0.12890625
>>> sample = sequence.generate(64)
>>> print(sequence.computeStarDiscrepancy(sample))
0.0537109375
generate(self, *args)

Generate a sample of pseudo-random vectors of numbers uniformly distributed over [0, 1).

Parameters
sizeint

Number of points to be generated. Default is 1.

Returns
sampleSample

Sample of pseudo-random vectors of numbers uniformly distributed over [0, 1).

Examples

>>> import openturns as ot
>>> # Create a sequence of 3 points of 2 dimensions
>>> sequence = ot.LowDiscrepancySequence(ot.SobolSequence(2))
>>> print(sequence.generate(3))
0 : [ 0.5  0.5  ]
1 : [ 0.75 0.25 ]
2 : [ 0.25 0.75 ]
getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getDimension(self)

Accessor to the dimension of the points of the low discrepancy sequence.

Returns
dimensionint

Dimension of the points of the low discrepancy sequence.

getId(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getImplementation(self, *args)

Accessor to the underlying implementation.

Returns
implImplementation

The implementation class.

getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

initialize(self, dimension)

Initialize the sequence.

Parameters
dimensionint

Dimension of the points of the low discrepancy sequence.

Examples

>>> import openturns as ot
>>> # Create a sequence of 3 points of 2 dimensions
>>> sequence = ot.LowDiscrepancySequence(ot.SobolSequence(2))
>>> print(sequence.generate(3))
0 : [ 0.5  0.5  ]
1 : [ 0.75 0.25 ]
2 : [ 0.25 0.75 ]
>>> print(sequence.generate(3))
0 : [ 0.375 0.375 ]
1 : [ 0.875 0.875 ]
2 : [ 0.625 0.125 ]
>>> sequence.initialize(2)
>>> print(sequence.generate(3))
0 : [ 0.5  0.5  ]
1 : [ 0.75 0.25 ]
2 : [ 0.25 0.75 ]
setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.