IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Num.SamplerUnitBallRandomFromCube Class Reference

Random sampling within the coordinate origin-centered hyper ball with radius one; derived from uniform random sampling of unit cube by radially stretching (or shrinking) the cube surface in order to fit the ball surface. More...

+ Inheritance diagram for IG.Num.SamplerUnitBallRandomFromCube:
+ Collaboration diagram for IG.Num.SamplerUnitBallRandomFromCube:

Public Member Functions

 SamplerUnitBallRandomFromCube (int spaceDimension, IRandomGenerator rand)
 Construct a new sampling object with the specified random generator that is used for creating new sampling points. More...
 
override void GetSamplingPoint (ref IVector samplingPoint)
 Creates the next sampling point and stores it to the specified vector. More...
 
- Public Member Functions inherited from IG.Num.SamplerBaseRandom
 SamplerBaseRandom (int spaceDimension, IRandomGenerator rand)
 Construct a new sampling object with the specified random generator that is used for creating new sampling points. More...
 
void SetRandomGenerator (IRandomGenerator rand)
 Sets the random generator that will be used for generation of sampling points. More...
 
- Public Member Functions inherited from IG.Num.SamplerBase
 SamplerBase (int spaceDimension)
 Constructs a new sampling point generator for the specified dimension of sampling space. More...
 
virtual void GetSamplingPoints (int numPoints, ref IVector[] samplingPoints)
 Creates the specified number of next sampling points and stores it to the specified array of vectors. More...
 
void ResizeSamplingPoints (int numPoints, ref IVector[] samplingPoints)
 Auxiliary method that resizes the array of sampling points, and also the vectors contained in it, as necessary. More...
 

Static Public Member Functions

static void TestSampleNorms (int dimension, int numGenerated)
 Generates the specified number of samples of the specified dimension, and prints distances from the coordinate origin to the console. A warning is printed whenever a distance is greater thatn 1. More...
 
static void TestSamplingSpeed (int dimension, int numGenerated)
 Generates the specified number of samples of the specified dimension, and prints distances from the coordinate origin to the console. A warning is printed whenever a distance is greater thatn 1. More...
 

Additional Inherited Members

- Protected Attributes inherited from IG.Num.SamplerBase
int _spaceDimension
 
- Properties inherited from IG.Num.SamplerBaseRandom
IRandomGenerator Random [get, protected set]
 The random generator that will be used for generation of sampling points. If it is null, the next call to getter will automatically assign it to the global random generator. More...
 
- Properties inherited from IG.Num.SamplerBase
object Lock [get]
 This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
 
int SpaceDimension [get, protected set]
 
- Properties inherited from IG.Num.ISampler
int SpaceDimension [get]
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Detailed Description

Random sampling within the coordinate origin-centered hyper ball with radius one; derived from uniform random sampling of unit cube by radially stretching (or shrinking) the cube surface in order to fit the ball surface.

Sampling procedure is as follows:

A reference sample is first generated by uniform random sampling proxedure for a zero centered cube with side lengths equal to 1. Then, the reference sample is mapped by a non-smooth mapping that maps the surface of the hyper cube into the surface of the origin-centered hyper ball with radius 1. Mapping maps in radial directions of the reference sample. It fisrt extends the reference sample's radius vector to the the cube surface (this is simply done by multiplying the vector by a factor that sets maximal absolute vector eleemnt to 0.5) in order to calculate the distance on the cube surface (in the direction of the sample) from the origin. Then, the generated reference sample is divided by this distance, ensuring that actual samples generated in the same direction will fit exactly within the unit ball.

This procedure produces random samples whose density is larger around the cube corners.

$A Igor xx;

Constructor & Destructor Documentation

IG.Num.SamplerUnitBallRandomFromCube.SamplerUnitBallRandomFromCube ( int  spaceDimension,
IRandomGenerator  rand 
)
inline

Construct a new sampling object with the specified random generator that is used for creating new sampling points.

Constructed sampler object generates random samples within a hzper ball with radius 1 centered around the coordinate origin.

Random generator can be null, in which case a global random generator will be used.

Parameters
spaceDimensionDimension of the sampled space.
randThe random generator that will be used for generation of sampling points. It can be null, in which case the global random generator will be used.

Member Function Documentation

override void IG.Num.SamplerUnitBallRandomFromCube.GetSamplingPoint ( ref IVector  samplingPoint)
inline

Creates the next sampling point and stores it to the specified vector.

Parameters
samplingPointVector where the generated sampling point is stored.

Implements IG.Num.ISampler.

References IG.Num.IRandomGenerator.NextDouble(), and IG.Num.VectorBase.Resize().

static void IG.Num.SamplerUnitBallRandomFromCube.TestSampleNorms ( int  dimension,
int  numGenerated 
)
inlinestatic

Generates the specified number of samples of the specified dimension, and prints distances from the coordinate origin to the console. A warning is printed whenever a distance is greater thatn 1.

Parameters
dimensionDimension of the sampling space.
numGeneratedNumber of samples generated.

References IG.Num.ISampler.GetSamplingPoint().

static void IG.Num.SamplerUnitBallRandomFromCube.TestSamplingSpeed ( int  dimension,
int  numGenerated 
)
inlinestatic

Generates the specified number of samples of the specified dimension, and prints distances from the coordinate origin to the console. A warning is printed whenever a distance is greater thatn 1.

Parameters
dimensionDimension of the sampling space.
numGeneratedNumber of samples generated.

References IG.Num.ISampler.GetSamplingPoint(), IG.Lib.StopWatch1.Start(), IG.Lib.StopWatch1.Stop(), and IG.Lib.StopWatch1.TotalTime.

Referenced by IG.Script.Script_Numeric.TestSampling().


The documentation for this class was generated from the following file: