lds_py package

Submodules

lds_py.ilds module

class lds_py.ilds.Halton(base: Sequence[int], scale: Sequence[int])[source]

Bases: object

Halton sequence generator

The Halton class is a sequence generator that generates points in a 2-dimensional space using the Halton sequence. The Halton sequence is a low-discrepancy sequence that is often used in quasi-Monte Carlo methods. It is generated by iterating over two different bases and calculating the fractional parts of the numbers in those bases. The Halton class keeps track of the current count and bases, and provides a pop() method that returns the next point in the sequence as a List[int].

Examples

>>> hgen = Halton([2, 3], [11, 7])
>>> hgen.reseed(0)
>>> for _ in range(10):
...     print(hgen.pop())
...
[1024, 729]
[512, 1458]
[1536, 243]
[256, 972]
[1280, 1701]
[768, 486]
[1792, 1215]
[128, 1944]
[1152, 81]
[640, 810]
pop() List[int][source]

The pop function returns a list of two integers by popping elements from vdc0 and vdc1. :return: The pop method is returning a list of two integers.

reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

class lds_py.ilds.VdCorput(base: int = 2, scale: int = 10)[source]

Bases: object

pop() int[source]

The pop() function is a member function of the VdCorput class that increments the count and calculates the next value in the Van der Corput sequence. :return: The pop() function is returning an int value.

Examples

>>> vdc = VdCorput(2, 10)
>>> vdc.pop()
512
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

Examples

>>> vdc = VdCorput(2, 10)
>>> vdc.reseed(0)
>>> vdc.pop()
512
lds_py.ilds.vdc_i(k: int, base: int = 2, scale: int = 10) int[source]

The function vdc_i converts a given number k from base base to a decimal number using a specified scale.

Parameters:

k – The parameter k represents the number for which we want to calculate the van der Corput

sequence value :type k: int :param base: The base parameter represents the base of the number system being used. In this case, it is set to 2, which means the number system is binary (base 2), defaults to 2 :type base: int (optional) :param scale: The scale parameter determines the precision or number of digits after the decimal point in the resulting VDC (Van der Corput) sequence. It specifies the number of times the base is raised to calculate the factor, defaults to 10 :type scale: int (optional) :return: The function vdc_i returns an integer value.

Examples

>>> vdc_i(1, 2, 10)
512

lds_py.lds module

class lds_py.lds.Circle(base: int)[source]

Bases: object

Circle sequence generator

Examples

>>> cgen = Circle(2)
>>> cgen.reseed(0)
>>> for _ in range(2):
...     print(cgen.pop())
...
[1.2246467991473532e-16, -1.0]
[1.0, 6.123233995736766e-17]
pop() List[float][source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> cgen = Circle(2)
>>> cgen.pop()
[1.2246467991473532e-16, -1.0]
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

vdc: VdCorput
class lds_py.lds.Halton(base: Sequence[int])[source]

Bases: object

Halton sequence generator

The Halton class is a sequence generator that generates points in a 2-dimensional space using the Halton sequence. The Halton sequence is a low-discrepancy sequence that is often used in quasi-Monte Carlo methods. It is generated by iterating over two different bases and calculating the fractional parts of the numbers in those bases. The Halton class keeps track of the current count and bases, and provides a pop() method that returns the next point in the sequence as a List[float].

Examples

>>> hgen = Halton([2, 3])
>>> hgen.reseed(0)
>>> for _ in range(10):
...     print(hgen.pop())
...
[0.5, 0.3333333333333333]
[0.25, 0.6666666666666666]
[0.75, 0.1111111111111111]
[0.125, 0.4444444444444444]
[0.625, 0.7777777777777777]
[0.375, 0.2222222222222222]
[0.875, 0.5555555555555556]
[0.0625, 0.8888888888888888]
[0.5625, 0.037037037037037035]
[0.3125, 0.37037037037037035]
pop() List[float][source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> hgen = Halton([2, 3])
>>> hgen.pop()
[0.5, 0.3333333333333333]
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

vdc0: VdCorput
vdc1: VdCorput
class lds_py.lds.HaltonN(n: int, base: Sequence[int])[source]

Bases: object

HaltonN sequence generator

Examples

>>> hgen = HaltonN(3, [2, 3, 5])
>>> hgen.reseed(0)
>>> for _ in range(2):
...     print(hgen.pop())
...
[0.5, 0.3333333333333333, 0.2]
[0.25, 0.6666666666666666, 0.4]
pop() List[float][source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> hgen = HaltonN(3, [2, 3, 5])
>>> hgen.pop()
[0.5, 0.3333333333333333, 0.2]
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

vdcs: List[VdCorput]
class lds_py.lds.Sphere(base: Sequence[int])[source]

Bases: object

Sphere sequence generator

Examples

>>> sgen = Sphere([2, 3])
>>> sgen.reseed(0)
>>> for _ in range(2):
...     print(sgen.pop())
...
[0.8660254037844387, -0.4999999999999998, 0.0]
[-0.7499999999999997, -0.4330127018922197, -0.5]
cirgen: Circle
pop() List[float][source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> sgen = Sphere([2, 3])
>>> sgen.pop()
[0.8660254037844387, -0.4999999999999998, 0.0]
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

vdc: VdCorput
class lds_py.lds.Sphere3Hopf(base: Sequence[int])[source]

Bases: object

Sphere3Hopf sequence generator

Examples

>>> sgen = Sphere3Hopf([2, 3, 5])
>>> sgen.reseed(0)
>>> for _ in range(2):
...     print(sgen.pop())
...
[-0.22360679774997885, 0.3872983346207417, 0.4472135954999573, 0.4472135954999573]
[-0.3162277660168382, -0.547722557505166, 0.6708203932499367, 0.6708203932499367]
pop() List[float][source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> sgen = Sphere3Hopf([2, 3, 5])
>>> sgen.pop()
[-0.22360679774997885, 0.3872983346207417, 0.4472135954999573, 0.4472135954999573]
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

vdc0: VdCorput
vdc1: VdCorput
vdc2: VdCorput
class lds_py.lds.VdCorput(base: int = 2)[source]

Bases: object

Van der Corput sequence generator

VdCorput is a class that generates the Van der Corput sequence. The Van def Corput sequence is a low-discrepancy sequence that is commonly used in quasi-Monte Carlo methods. The sequence is generated by iterating over a base and calculating the fractional part of the number in that base. The VdCorput class keeps track of the current count and base, and provides a pop() method that returns the next value in the sequence.

Examples

>>> vgen = VdCorput(2)
>>> vgen.reseed(0)
>>> for _ in range(10):
...     print(vgen.pop())
...
0.5
0.25
0.75
0.125
0.625
0.375
0.875
0.0625
0.5625
0.3125
base: int
count: int
pop() float[source]

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a List[float; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a List[float; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a List[float; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a List[float; 4].

Examples

>>> vgen = VdCorput(2)
>>> vgen.pop()
0.5
reseed(seed: int) None[source]

The reseed(size_t seed) function is used to reset the state of the sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning, or from a specific point in the sequence, depending on the value of the seed.

Parameters:

seed (int) – _description_

lds_py.lds.vdc(k: int, base: int = 2) float[source]

Van der Corput sequence

The function vdc converts a given number k from base base to a floating point number.

Parameters:

k – The parameter k represents the number for which we want to calculate the van der Corput

sequence value :type k: int :param base: The base parameter represents the base of the number system being used. In this case, it is set to 2, which means the number system is binary (base 2), defaults to 2 :type base: int (optional) :return: The function vdc returns a floating point value.

Examples

>>> vdc(11, 2)
0.8125

Module contents