BRL-CAD
Sobol quasi-random low-discrepancy sequences of numbers

Generation of the Sobol quasi-random low-discrepancy sequence of numbers. More...

Collaboration diagram for Sobol quasi-random low-discrepancy sequences of numbers:

Files

file  sobol.h
 

Macros

#define BN_SOBOL_MAXDIM   1111
 

Functions

struct bn_soboldata * bn_sobol_create (unsigned int sdim, unsigned long seed)
 
void bn_sobol_destroy (struct bn_soboldata *s)
 
double * bn_sobol_next (struct bn_soboldata *s, const double *lb, const double *ub)
 
void bn_sobol_skip (struct bn_soboldata *s, unsigned n)
 
void bn_sobol_sph_sample (point_t sample, const point_t center, const fastf_t radius, struct bn_soboldata *s)
 Generate a sample point on a sphere per Marsaglia (1972), using the Sobol data sequence s to drive the selection. More...
 

Detailed Description

Generation of the Sobol quasi-random low-discrepancy sequence of numbers.

Usage:
double *snums;
struct bn_soboldata *sd = bn_sobol_create(3, time(NULL));
if (sd) {
bn_sobol_skip(s, 4000, snums);
for (i = 0; i < 4000; i++) {
snums = bn_sobol_next(s, NULL, NULL);
printf("x[%d]: %g %g %g", i, snums[0], snums[1], snums[2]);
}
}
void bn_sobol_skip(struct bn_soboldata *s, unsigned n)
double * bn_sobol_next(struct bn_soboldata *s, const double *lb, const double *ub)
struct bn_soboldata * bn_sobol_create(unsigned int sdim, unsigned long seed)
void bn_sobol_destroy(struct bn_soboldata *s)

Macro Definition Documentation

◆ BN_SOBOL_MAXDIM

#define BN_SOBOL_MAXDIM   1111

Maximum dimension of Sobol output array

Definition at line 59 of file sobol.h.

Function Documentation

◆ bn_sobol_create()

struct bn_soboldata * bn_sobol_create ( unsigned int  sdim,
unsigned long  seed 
)

Create and initialize an instance of a Sobol sequence data container. If seed is non-zero the value will be used in initialization, otherwise a default will be used. User must destroy the returned data with bn_sobol_destroy

◆ bn_sobol_destroy()

void bn_sobol_destroy ( struct bn_soboldata *  s)

Destroy a Sobol data container

◆ bn_sobol_next()

double * bn_sobol_next ( struct bn_soboldata *  s,
const double *  lb,
const double *  ub 
)

Return the next vector in Sobol sequence, scaled to (lb[i], ub[i]) interval.

If lb and ub are NULL, x[i] will be in the range (0,1).

The return vector is read only and is managed internally by bn_sobodata.

Note: not performing the scale saves some math operations, so NULL lb and ub are recommend if the required interval for the caller's application happens to be (0,1).

Note: If the user attempts to read more than 2^32-1 points from the sequence, the generator will fall back on pseudo random number generation.

◆ bn_sobol_skip()

void bn_sobol_skip ( struct bn_soboldata *  s,
unsigned  n 
)

If the caller knows in advance how many numbers (n) they want to compute, this function supports implementation of the Acworth et al (1998) strategy of skipping a number of points equal to the largest power of 2 smaller than n for better performance.

Joe and Kuo indicate in their notes at http://web.maths.unsw.edu.au/~fkuo/sobol/ that they are "less persuaded" by this recommendation, but this function is available for callers who wish to use it.

◆ bn_sobol_sph_sample()

void bn_sobol_sph_sample ( point_t  sample,
const point_t  center,
const fastf_t  radius,
struct bn_soboldata *  s 
)

Generate a sample point on a sphere per Marsaglia (1972), using the Sobol data sequence s to drive the selection.

The caller is responsible for initializing the bn_sobodata sequence before generating points.

TODO: investigate the http://www.dtic.mil/docs/citations/ADA510216 scrambling method to see if basic Sobol sequence can be improved on for spherical sampling Also relevant: people.sc.fsu.edu/~hcc8471/ssobol.pdf