Sampler Dart Throwing [MF92]
Description
A naive (relaxed) dart throwing algorithm.
For a more precise description of this sampler and its performances in terms of aliasing and discrepancy, please refer to the following web bundle https://liris.cnrs.fr/ldbn/HTML_bundle/index.html.
Files
src/samplers/DartThrowing.cpp
include/utk/samplers/SamplerDartThrowing.hpp
Usage
Dart Throwing sampler
Usage: ./src/samplers/DartThrowing [OPTIONS]
Options:
-h,--help Print this help message and exit
-n UINT REQUIRED Number of points
-d UINT REQUIRED Dimensions
-s,--seed UINT Seed (unspecified means 'random')
-m UINT [1] Number of pointsets
-o,--out TEXT [out.dat] Output file (format). {i} splits outputs in multiple files and token is replaced by index.
--silent Silence UTK logs
--relax [1] Enable relaxation
--euclidean [0] Use euclidean distance (default is wrap around)
--relax_factor FLOAT [0.9] Amount of relaxation applied after too many unsucessful trials
--trials UINT [1000] Number of trials before relaxation occurs
--distance FLOAT [-1] Minimal distance to use (will be scaled by N^-D !). If negative use precomputed sphere packing values (meaningfull only when D < 9)
#include <utk/utils/PointsetIO.hpp>
#include <utk/utils/Pointset.hpp>
#include <utk/samplers/SamplerDartThrowing.hpp>
int main()
{
utk::Pointset<double> pts;
utk::SamplerDartThrowing dt(
2 /* dimension */
true, /* true = relaxed, false = not relaxed */
false, /* false = euclidean distance, true = toroidal*/
1000, /* trials before relaxing distance */
0.9, /* Relaxation factor */
-1 /* Distance (-1 = precomputed sphere packing values) */
);
dt.setRandomSeed(/* Or a seed */);
// Check for no errors
if (dt.generateSamples(pts, 1024 /* Number of points */))
{
write_text_pointset("dt2d.dat", pts);
}
}
import pyutk
dt = pyutk.DartThrowing(
2, # dimension,
True, # true = relaxed, false = not relaxed
False, # false = euclidean distance, true = toroidal
1000, # trials before relaxing distance
0.9, # Relaxation factor
-1 # Distance (-1 = precomputed sphere packing values)
)
samples = dt.sample(1024) # This is a numpy array !
Results
License
See Licence.md file.