libfbm  0.3
Simulation of multi-dimensional stationary Gaussian processes and fractional Brownian motion.
 All Classes Namespaces Functions Variables Friends
Public Member Functions | Static Public Member Functions | Protected Member Functions
libfbm::FBMSteinContext Class Reference

Stein's fractional Brownian motion context. More...

#include <libfbm.hpp>

Inheritance diagram for libfbm::FBMSteinContext:
libfbm::SGPContext

List of all members.

Public Member Functions

 FBMSteinContext (double H, size_t dim, size_t size, double Rhint=-1, bool mapDim=true)
 Construct the Stein's FBM context object of size size^dim.
double cov (const zvec &zvec)
 Covariance function.
void disablePostProcessing ()
double getR () const
 Get the parameter R described in [3].
- Public Member Functions inherited from libfbm::SGPContext
 SGPContext (const zvec &fieldDim, const zvec &userDim, const std::string &cacheName)
 Constructor.
virtual ~SGPContext ()
const zvecgetDim () const
 Get the usable dimension of the generated field.
const zvecgetFieldDim () const
 Get the physical dimension of the generated field.
void setCacheDir (const std::string &cacheDir)
 Set the cache directory.
size_t badEigenCount () const
 Return the number of bad eigenvalues encountered.
bool initCache (bool forceRecalc=false)
 Initialize the cache.

Static Public Member Functions

static size_t userSize2FieldSize (size_t size, double R)
 Get the required field size for the given usable user size and R.
static size_t fieldSize2UserSize (size_t size, double R)
 Map the field dimension into the resulting usable fBm field dimension.
static double getRForH (double H, size_t dim, double Rhint=-1)
 Get the precomputed R value for the given H.

Protected Member Functions

void postProcess (Field &field, GaussianGenerator &rng)
 Postprocessor called after field generation.
- Protected Member Functions inherited from libfbm::SGPContext
void setScaleResult (double f)
 Scale the output values by factor f.

Detailed Description

Stein's fractional Brownian motion context.

Stein [3] defines fBm as a random process Z with a power-law increment variance:

\[ \mbox{Var}\!\left(\left| Z\!\left(\mathbf{x}\right)-Z\!\left(\mathbf{y}\right)\right|^2\right)\propto\left|\mathbf{x}-\mathbf{y}\right|^{2H}, \]

however, the covariance does not match that of a "standard" fBm. Indeed, for Stein it is actually

\[ \mbox{Cov}\!\left(Z\!\left(\mathbf{x}\right),Z\!\left(\mathbf{y}\right)\right)=c0-\left|\mathbf{x}-\mathbf{y}\right|^{2H}+c_2\left(\left|\mathbf{x}\right|^2+\left|\mathbf{y}^2\right|\right). \]

The FBMSteinContext changes the actual genereated field dimension. However, only part of it, that is the dimension given at construction is usable, the rest is used for the Stein's embedding method. This means the getDim() and getFieldDim() may have different values. The Field::getDim() reflects the usable area.

Definition at line 931 of file libfbm.hpp.


Constructor & Destructor Documentation

libfbm::FBMSteinContext::FBMSteinContext ( double  H,
size_t  dim,
size_t  size,
double  Rhint = -1,
bool  mapDim = true 
)

Construct the Stein's FBM context object of size size^dim.

Parameters:
HThe Hurst exponent.
dimDimensionality of the field wanted (1D, 2D, 3D, etc.).
sizeRequest field of size^dim.
RhintHint that overrides the self-determined R (see getRforH()). See [3] for details but in general 1<=R<=2. Larger R wastes more space and takes more time to calculate; smaller R may result in negative eigenvalues and a failed calculation. So one strives towards smallest R possible that works (no negative eigenvalues). As field size is increased (or field dimension), R must also increase. If left negative, the program attempts to estimate the value based on parameter H and dimensionality, but this estimate is conservative.
mapDimExpand dimension so that the resulting usable field is the size requested. True by default.

The automatic R detections seems to work well for 2D case. For higher-dimensional cases you may have to fiddle with it manually.


Member Function Documentation

double libfbm::FBMSteinContext::cov ( const zvec p)
virtual

Covariance function.

Implements libfbm::SGPContext.

void libfbm::FBMSteinContext::disablePostProcessing ( )
static size_t libfbm::FBMSteinContext::fieldSize2UserSize ( size_t  size,
double  R 
)
static

Map the field dimension into the resulting usable fBm field dimension.

double libfbm::FBMSteinContext::getR ( ) const
inline

Get the parameter R described in [3].

Definition at line 961 of file libfbm.hpp.

static double libfbm::FBMSteinContext::getRForH ( double  H,
size_t  dim,
double  Rhint = -1 
)
static

Get the precomputed R value for the given H.

This function is quantized, so is not optimal. Also R depends a bit on the size of the field. This here is conservative. However, it could be it fails for some cases, then you need to provide your own correct R. The returned value is a very conservative 2.0 when dim >= 3, so for 3D and higher-dimensional cases it makes sense to find your own optimal R value.

Parameters:
RhintIf equal or greater than 1, return Rhint.
void libfbm::FBMSteinContext::postProcess ( Field field,
GaussianGenerator rng 
)
protectedvirtual

Postprocessor called after field generation.

This is called automatically by Field::generate().

Reimplemented from libfbm::SGPContext.

static size_t libfbm::FBMSteinContext::userSize2FieldSize ( size_t  size,
double  R 
)
static

Get the required field size for the given usable user size and R.

Stein's method [2] requires a larger field to generate a field for the required initial dimensions. This size depends on the chosen R. For 2D and H <= 0.75, R is always 1.0. For H > 0.75, R must be increased. It is proven that the methdod works with R=2.0. However, in practice R=1.3 at H=0.999 works just fine.


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