@Reference(title="Randomized halton sequences", authors="X. Wang, F. J. Hickernell", booktitle="Mathematical and Computer Modelling Vol. 32 (7)", url="https://doi.org/10.1016/S0895-7177(00)00178-3", bibkey="doi:10.1016/S0895-71770000178-3") public class HaltonUniformDistribution extends java.lang.Object implements Distribution
Technically, they are based on Van der Corput sequence and the Von Neumann Katutani transformation. These produce a series of integers which then are converted to floating point values.
To randomize, we just choose a random starting position, as indicated by
Reference:
X. Wang, F. J. Hickernell
Randomized halton sequences
Mathematical and Computer Modelling Vol. 32 (7)
Important note: this code hasn't been double checked yet. While it probably works for some simple cases such as example data set generation, do not rely on it for e.g. quasi monte carlo methods without double-checking the quality, and looking at more advanced methods!
Let me repeat this: this code was written to generate toy datasets. It may have deficits for other uses! There is a high chance it will produce correlated data when used for more than one dimension. - for toy data sets, try different random seeds until you find one that works for you.
TODO: find an improved algorithm that takes care of a better randomization, for example by adding scrambling.
Modifier and Type | Class and Description |
---|---|
static class |
HaltonUniformDistribution.Parameterizer
Parameterization class
TODO: allow manual parameterization of sequence parameters!
|
Modifier and Type | Field and Description |
---|---|
private static double |
ALMOST_ONE
Threshold
|
(package private) short |
base
Base value
|
(package private) int |
counter
Counter, for max iterations of fast function.
|
(package private) double |
current
Current value
|
(package private) double |
invbase
Inverse of base, for faster division by multiplication.
|
(package private) long |
inverse
Integer inverse
|
private double |
len
Len := max - min
|
(package private) double |
logbase
Logarithm of base.
|
private double |
max
Maximum
|
private static int |
MAXFAST
Maximum number of iterations of fast variant
|
(package private) int |
maxi
Maximum integer to use
|
private double |
min
Minimum
|
Constructor and Description |
---|
HaltonUniformDistribution(double min,
double max)
Constructor for a halton pseudo uniform distribution on the interval [min,
max[
|
HaltonUniformDistribution(double min,
double max,
int base,
double seed)
Constructor for a halton pseudo uniform distribution on the interval [min,
max[
|
HaltonUniformDistribution(double min,
double max,
java.util.Random rnd)
Constructor for a halton pseudo uniform distribution on the interval [min,
max[
|
HaltonUniformDistribution(double min,
double max,
RandomFactory rnd)
Constructor for a halton pseudo uniform distribution on the interval [min,
max[
|
Modifier and Type | Method and Description |
---|---|
double |
cdf(double val)
Return the cumulative density function at the given value.
|
private static int |
choosePrime(java.util.Random rnd)
Choose a random prime.
|
double |
getMax() |
double |
getMin() |
private long |
inverse(double current)
Compute the inverse with respect to the given base.
|
double |
logpdf(double val)
Return the log density of an existing value
|
private double |
nextRadicalInverse()
Compute the next radical inverse.
|
double |
nextRandom()
Generate a new random value
|
double |
pdf(double val)
Return the density of an existing value
|
double |
quantile(double val)
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.
|
private double |
radicalInverse(long i)
Compute the radical inverse of i.
|
java.lang.String |
toString()
Describe the distribution
|
private double min
private double max
private double len
private static final int MAXFAST
private static final double ALMOST_ONE
final short base
final double invbase
final double logbase
final int maxi
int counter
double current
long inverse
public HaltonUniformDistribution(double min, double max, int base, double seed)
min
- Minimum valuemax
- Maximum valuebase
- Base valueseed
- Random seed (starting value)public HaltonUniformDistribution(double min, double max)
min
- Minimum valuemax
- Maximum valuepublic HaltonUniformDistribution(double min, double max, java.util.Random rnd)
min
- Minimum valuemax
- Maximum valuernd
- Random generatorpublic HaltonUniformDistribution(double min, double max, RandomFactory rnd)
min
- Minimum valuemax
- Maximum valuernd
- Random generatorprivate static int choosePrime(java.util.Random rnd)
rnd
- Random generatorpublic double pdf(double val)
Distribution
pdf
in interface Distribution
val
- existing valuepublic double logpdf(double val)
Distribution
logpdf
in interface Distribution
val
- existing valuepublic double cdf(double val)
Distribution
cdf
in interface Distribution
val
- existing valuepublic double quantile(double val)
Distribution
quantile
in interface Distribution
val
- Quantile to findprivate long inverse(double current)
current
- Current valueprivate double radicalInverse(long i)
i
- Input long valueprivate double nextRadicalInverse()
public double nextRandom()
Distribution
nextRandom
in interface Distribution
public java.lang.String toString()
Distribution
toString
in interface Distribution
toString
in class java.lang.Object
public double getMin()
public double getMax()
Copyright © 2019 ELKI Development Team. License information.