These quasirandom (low-discrepancy) sequences are based on the blogpost "The Unreasonable Effectiveness of Quasirandom Sequences":
http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
points1D : Basics.Int -> List Basics.Float
Generate a low-discrepancy sequence of N points in the [0,1)
interval.
points2D : Basics.Int -> List ( Basics.Float, Basics.Float )
Generate a low-discrepancy sequence of N points in the [0,1)^2
space.
points3D : Basics.Int -> List ( Basics.Float, Basics.Float, Basics.Float )
Generate a low-discrepancy sequence of N points in the [0,1)^3
space.
points : { dimensions : Basics.Int, count : Basics.Int } -> List (List Basics.Float)
A generalized way to generate N points in D dimensions (each dimension
confined to the [0,1)
interval).
The returned data is in shape:
[ point0, point1, point2, ... ]
Where each point is structured like
[ x, y, ... ]
Here's an example:
points { dimensions = 1, count = 100 }
--> [ [x0], [x1], [x2], [x3], [x4], ... ]
points { dimensions = 2, count = 100 }
--> [ [x0, y0], [x1, y1], [x2, y2], [x3, y3], [x4, y4], ... ]
etc.
If you want a randomized sequence, use pointsGen
.
points1DGen : Basics.Int -> Random.Generator (List Basics.Float)
Generate a randomized low-discrepancy sequence of N points in the [0,1)
interval.
points2DGen : Basics.Int -> Random.Generator (List ( Basics.Float, Basics.Float ))
Generate a randomized low-discrepancy sequence of N points in the [0,1)^2
space.
points3DGen : Basics.Int -> Random.Generator (List ( Basics.Float, Basics.Float, Basics.Float ))
Generate a randomized low-discrepancy sequence of N points in the [0,1)^3
space.
pointsGen : { dimensions : Basics.Int, count : Basics.Int } -> Random.Generator (List (List Basics.Float))
A randomized generalized way to generate N points in D dimensions (each
dimension confined to the [0,1)
interval).
The returned data is in shape:
[ point0, point1, point2, ... ]
Where each point is structured like
[ x, y, ... ]
depending on the number of dimensions. Here's an example from the non-randomized function:
points { dimensions = 1, count = 100 }
--> [ [x0], [x1], [x2], [x3], [x4], ... ]
points { dimensions = 2, count = 100 }
--> [ [x0, y0], [x1, y1], [x2, y2], [x3, y3], [x4, y4], ... ]
etc.
next1D : Basics.Float -> Basics.Float
Given a point in the [0,1)
interval, generate another one in the
low-discrepancy sequence.
Given enough of these, they will cover the interval uniformly.
Note that if you need to generate these numbers on multiple axes, you should
instead use nextForDimension
and give each axis a different dimension
value.
next2D : ( Basics.Float, Basics.Float ) -> ( Basics.Float, Basics.Float )
Given a point in the [0,1)^2
space, generate another one in the
low-discrepancy sequence.
Given enough of these, they will cover the space uniformly.
next3D : ( Basics.Float, Basics.Float, Basics.Float ) -> ( Basics.Float, Basics.Float, Basics.Float )
Given a point in the [0,1)^3
space, generate another one in the
low-discrepancy sequence.
Given enough of these, they will cover the space uniformly.
next : List Basics.Float -> List Basics.Float
Given a N-dimensional point, generate another one in the low-discrepancy sequence.
Given enough of these, they will cover the space uniformly.
nextForDimension : Basics.Int -> Basics.Float -> Basics.Float
Given a point component for a given dimension, generate another one in the low-discrepancy sequence.
Given enough of these, they will cover the space uniformly.
Note that if d1 /= d2
then nextForDimension d1 x /= nextForDimension d2 x
.
This is a good thing!
nth1D : Basics.Int -> Basics.Float
Generate n-th point in the 1D low-discrepancy sequence.
Note that for speed with large n
s, this uses a multiplicative algorithm
instead of an additive one that's used by points*
and next*
, resulting in a
slight loss of precision, and so the sequences generated using nth*
will
eventually diverge from the sequences generated using the rest of the functions
in this module.
nth2D : Basics.Int -> ( Basics.Float, Basics.Float )
Generate n-th point in the 2D low-discrepancy sequence.
Note that for speed with large n
s, this uses a multiplicative algorithm
instead of an additive one that's used by points*
and next*
, resulting in a
slight loss of precision, and so the sequences generated using nth*
will
eventually diverge from the sequences generated using the rest of the functions
in this module.
nth3D : Basics.Int -> ( Basics.Float, Basics.Float, Basics.Float )
Generate n-th point in the 3D low-discrepancy sequence.
Note that for speed with large n
s, this uses a multiplicative algorithm
instead of an additive one that's used by points*
and next*
, resulting in a
slight loss of precision, and so the sequences generated using nth*
will
eventually diverge from the sequences generated using the rest of the functions
in this module.
nth : { dimensions : Basics.Int, n : Basics.Int } -> List Basics.Float
Generate n-th point in the N-dimensional low-discrepancy sequence.
Note that for speed with large n
s, this uses a multiplicative algorithm
instead of an additive one that's used by points*
and next*
, resulting in a
slight loss of precision, and so the sequences generated using nth*
will
eventually diverge from the sequences generated using the rest of the functions
in this module.
nthForDimension : { dimension : Basics.Int, n : Basics.Int } -> Basics.Float
Generate n-th point's component for the n-th dimension in the low-discrepancy sequence.
Note that for speed with large n
s, this uses a multiplicative algorithm
instead of an additive one that's used by points*
and next*
, resulting in a
slight loss of precision, and so the sequences generated using nth*
will
eventually diverge from the sequences generated using the rest of the functions
in this module.