random sampling
0.0.0Functions to generate random samples with various distributions
About RandomSampling
This library provides additional functions used in statistics or random generation. It provides a variety of distribution functions to provide a biased random number generation and generators for random numbers on 3D volumes.
How To
This library relies on randomstate for uniform random number generation. As such, you can pick from a variety of underlying sources of randomness to drive the other algorithms in this library. For multivariate distributions such as over volumes, it relies on the 3dmath library for vector and matrix representation.
To generate samples, simply invoke one of the various functions exposed by this library. To influence the underlying random source, set or bind the org.shirakumo.randomstate:*generator*
.
Sampling for the following volume types is available:
The following distribution functions are available:
Most distributions also have their probility density function available. You can retrieve it via the pdf
function.
System Information
Definition Index

ORG.SHIRAKUMO.RANDOMSAMPLING
No documentation provided.
EXTERNAL FUNCTION BINOMIAL
 P
 N
 &OPTIONAL
 RESULT0
Draws a sample from the negative binomial distribution. See BINOMIAL See BINOMIALPDF See MAPSAMPLES

EXTERNAL FUNCTION BINOMIALPDF
 X
 P
 N

EXTERNAL FUNCTION BERNOULLI
 P
 &OPTIONAL
 RESULT0
Draws a sample from the Bernoulli distribution. See BERNOULLIPDF See MAPSAMPLES

EXTERNAL FUNCTION BERNOULLIPDF
 X
 P

EXTERNAL FUNCTION BETA
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the beta distribution. See BETAPDF See MAPSAMPLES

EXTERNAL FUNCTION BETAPDF
 X
 A
 B

EXTERNAL FUNCTION BINOMIAL
 P
 N
 &OPTIONAL
 RESULT0
Draws a sample from the binomial distribution. See BINOMIAL See BINOMIALPDF See MAPSAMPLES

EXTERNAL FUNCTION BINOMIALPDF
 X
 P
 N

EXTERNAL FUNCTION BOX
 BSIZE
 &OPTIONAL
 RESULT0
Samples a uniform box. BSIZE should be the halfsize of the box in each direction, with the box being centered at 0,0,0. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION CAUCHY
 A
 &OPTIONAL
 RESULT0
Draws a sample from the Cauchy distribution. See CAUCHYPDF See MAPSAMPLES

EXTERNAL FUNCTION CAUCHYPDF
 X
 A

EXTERNAL FUNCTION CHISQUARED
 NU
 &OPTIONAL
 RESULT0
Draws a sample from the chisquared distribution. See CHISQUAREDPDF See MAPSAMPLES

EXTERNAL FUNCTION CHISQUAREDPDF
 X
 NU
Computes the probability density of the given sample X under the chisquared distribution. See PDF See CHISQUARED

EXTERNAL FUNCTION CONVEXMESH
 VERTICES
 FACES
 &OPTIONAL
 RESULT0
Samples a uniform convex mesh. VERTICES must be a (SIMPLEARRAY SINGLEFLOAT (*)) that contains the packed representation of the vertex coordinates. FACES must be a (SIMPLEARRAY (UNSIGNEDBYTE 16) (*)) that contains the packed indices of the vertices that compose the faces. The vertices of each face must occur in counterclockwise order. Both arrays must have a length that is a multiple of 3. The consequences are undefined if the mesh described by VERTICES and FACES is not convex and manifold. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION CYLINDER
 RADIUS
 HEIGHT
 &OPTIONAL
 NORMAL
 RESULT0
Samples a uniform cylinder. HEIGHT is the halfheight of the cylinder with the cylinder's center always at 0,0,0. NORMAL may be a normalised vector pointing in the UP direction of the cylinder. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION DISC
 &OPTIONAL
 RADIUS
 NORMAL
 RESULT0
Samples a uniform disc. NORMAL may be a normalised vector pointing in the UP direction of the disc's plane. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION EXPONENTIAL
 MU
 &OPTIONAL
 RESULT0
Draws a sample from the exponential distribution. See EXPONENTIALPDF See MAPSAMPLES

EXTERNAL FUNCTION EXPONENTIALPDF
 X
 MU
Computes the probability density of the given sample X under the exponential distribution. See PDF See EXPONENTIAL

EXTERNAL FUNCTION FDIST
 NU1
 NU2
 &OPTIONAL
 RESULT0
Draws a sample from the F distribution. See FDISTPDF See MAPSAMPLES

EXTERNAL FUNCTION FDISTPDF
 X
 NU1
 NU2

EXTERNAL FUNCTION FLAT
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the flat distribution. See FLATPDF See MAPSAMPLES

EXTERNAL FUNCTION FLATPDF
 X
 A
 B

EXTERNAL FUNCTION GAMMA
 A
 &OPTIONAL
 B
 RESULT0
Draws a sample from the gamma distribution. See GAMMAPDF See MAPSAMPLES

EXTERNAL FUNCTION GAMMAPDF
 X
 A
 &OPTIONAL
 B

EXTERNAL FUNCTION GAUSSIAN
 &OPTIONAL
 SIGMA
 RESULT0
Draws a sample from the Gaussian distribution. See GAUSSIANTAIL See GAUSSIANPDF See MAPSAMPLES

EXTERNAL FUNCTION GAUSSIANPDF
 X
 &OPTIONAL
 SIGMA

EXTERNAL FUNCTION GAUSSIANTAIL
 A
 &OPTIONAL
 SIGMA
 RESULT0
Draws a sample from the Gaussiantail distribution. See GAUSSIAN See GAUSSIANTAILPDF See MAPSAMPLES

EXTERNAL FUNCTION GAUSSIANTAILPDF
 X
 A
 &OPTIONAL
 SIGMA
Computes the probability density of the given sample X under the Gaussiantail distribution. See PDF See GAUSSIANTAIL

EXTERNAL FUNCTION GEOMETRIC
 P
 &OPTIONAL
 RESULT0
Draws a sample from the geometric distribution. See GEOMETRICPDF See MAPSAMPLES

EXTERNAL FUNCTION GEOMETRICPDF
 X
 P

EXTERNAL FUNCTION GUMBEL1
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the Gumbel1 distribution. See GUMBEL1PDF See MAPSAMPLES

EXTERNAL FUNCTION GUMBEL1PDF
 X
 A
 B

EXTERNAL FUNCTION GUMBEL2
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the Gumbel2 distribution. See GUMBEL2PDF See MAPSAMPLES

EXTERNAL FUNCTION GUMBEL2PDF
 X
 A
 B

EXTERNAL FUNCTION HALFSPHERE
 &OPTIONAL
 NORMAL
 RADIUS
 RESULT0
Samples a uniform halfsphere. RADIUS may either be a real of the radius, or a VEC3 to generate an ellipsoid. NORMAL may be a normalised vector pointing in the UP direction of the halfsphere. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION LAPLACE
 A
 &OPTIONAL
 RESULT0
Draws a sample from the Laplace distribution. See LAPLACEPDF See MAPSAMPLES

EXTERNAL FUNCTION LAPLACEPDF
 X
 A

EXTERNAL FUNCTION LEVY
 C
 ALPHA
 &OPTIONAL
 RESULT0
Draws a sample from the Levy distribution. See LEVYSKEW See MAPSAMPLES

EXTERNAL FUNCTION LEVYSKEW
 C
 ALPHA
 BETA
 &OPTIONAL
 RESULT0
Draws a sample from the Levyskew distribution. See LEVY See MAPSAMPLES

EXTERNAL FUNCTION LOGARITHMIC
 P
 &OPTIONAL
 RESULT0
Draws a sample from the logarithmic distribution. See LOGARITHMICPDF See MAPSAMPLES

EXTERNAL FUNCTION LOGARITHMICPDF
 X
 P
Computes the probability density of the given sample X under the logarithmic distribution. See PDF See LOGARITHMIC

EXTERNAL FUNCTION LOGISTIC
 A
 &OPTIONAL
 RESULT0
Draws a sample from the logistic distribution. See LOGISTICPDF See MAPSAMPLES

EXTERNAL FUNCTION LOGISTICPDF
 X
 A

EXTERNAL FUNCTION LOGNORMAL
 ZETA
 SIGMA
 &OPTIONAL
 RESULT0
Draws a sample from the lognormal distribution. See LOGNORMALPDF See MAPSAMPLES

EXTERNAL FUNCTION LOGNORMALPDF
 X
 ZETA
 SIGMA

EXTERNAL FUNCTION MAPSAMPLES
 RESULT
 SAMPLE1
Gathers samples into RESULT, drawing them from SAMPLE1. RESULT may be one of the following: NULL  A single singlefloat is sampled and returned INTEGER  An array of result size is sampled and returned SEQUENCE  Each element of the sequence is set to a fresh sample SAMPLE1 must be a function of zero arguments and must return the freshly drawn sample as a singlefloat. This function is implicitly used by every distribution sampling function. The optional RESULT argument of those functions corresponds to the above.

EXTERNAL FUNCTION MAPVOLUMESAMPLES
 RESULT
 SAMPLE1
Gathers samples into RESULT, drawing them from SAMPLE1. RESULT may be one of the following: NULL  A fresh VEC3 is sampled and returned VEC3  The result is sampled and returned INTEGER  An array of result size is sampled and returned SEQUENCE  Each element of result is sampled and result is returned. Each element of result must be a VEC3 SAMPLE1 must be a function of one argument, a VEC3, and must return said VEC3 after performing its sampling operation to fill the vector's elements. This function is implicitly used by every volume sampling function. The optional RESULT argument of those functions corresponds to the above.

EXTERNAL FUNCTION NORMAL
 &OPTIONAL
 RADIUS
 RESULT0
Samples a uniform normal vector. This is equivalent to sampling the surface of a sphere. RADIUS may either be a real of the radius, or a VEC3 to generate an ellipsoid. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION PARETO
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the Pareto distribution. See PARETOPDF See MAPSAMPLES

EXTERNAL FUNCTION PARETOPDF
 X
 A
 B

EXTERNAL FUNCTION PDF
 DISTRIBUTION
 &OPTIONAL
 ERRORP
Returns the probability density function for the given distribution. The distribution must be given as a name. If no PDF exists, and errorp is true, an error is signalled. Every PDF takes the same arguments as its corresponding distribution function, plus an additional first argument, which is the sample for which to evaluate the PDF.

EXTERNAL FUNCTION PILL
 RADIUS
 HEIGHT
 &OPTIONAL
 NORMAL
 RESULT0
Samples a uniform pill. A pill is a cylinder with its caps being spheres. HEIGHT is the halfheight of the pill cylinder with the pill's center always at 0,0,0. If the height is zero, this is equivalent to a sphere. NORMAL may be a normalised vector pointing in the UP direction of the cylinder. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION POISSON
 MU
 &OPTIONAL
 RESULT0
Draws a sample from the Poisson distribution. See POISSONPDF See MAPSAMPLES

EXTERNAL FUNCTION POISSONPDF
 X
 MU

EXTERNAL FUNCTION RAYLEIGH
 SIGMA
 &OPTIONAL
 RESULT0
Draws a sample from the Rayleigh distribution. See RAYLEIGHTAIL See RAYLEIGHPDF See MAPSAMPLES

EXTERNAL FUNCTION RAYLEIGHPDF
 X
 SIGMA

EXTERNAL FUNCTION RAYLEIGHTAIL
 A
 SIGMA
 &OPTIONAL
 RESULT0
Draws a sample from the Rayleightail distribution. See RAYLEIGH See RAYLEIGHTAILPDF See MAPSAMPLES

EXTERNAL FUNCTION RAYLEIGHTAILPDF
 X
 A
 SIGMA
Computes the probability density of the given sample X under the Rayleightail distribution. See PDF See RAYLEIGHTAIL

EXTERNAL FUNCTION REJECTIONSAMPLE
 GENERATOR
 PREDICATE
 &OPTIONAL
 RESULT0
Perform rejection sampling using GENERATOR to draw samples and PREDICATE to determine whether to keep the sample. GENERATOR must be a function of one argument, the VEC3 to sample. PREDICATE must be a function of one argument, the VEC3 to examine, and must return true if the sample is suitable. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION SPHERE
 &OPTIONAL
 RADIUS
 RESULT0
Samples a uniform sphere. RADIUS may either be a real of the radius, or a VEC3 to generate an ellipsoid. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION TDIST
 NU
 &OPTIONAL
 RESULT0
Draws a sample from the T distribution. See TDISTPDF See MAPSAMPLES

EXTERNAL FUNCTION TDISTPDF
 X
 NU

EXTERNAL FUNCTION TRIANGLE
 P0
 P1
 P2
 &OPTIONAL
 RESULT0
Samples a uniform triangle. P0, P1, P2 designate the corners of the triangle. See MAPVOLUMESAMPLES

EXTERNAL FUNCTION WEIBULL
 A
 B
 &OPTIONAL
 RESULT0
Draws a sample from the Weibull distribution. See WEIBULLPDF See MAPSAMPLES

EXTERNAL FUNCTION WEIBULLPDF
 X
 A
 B
