libfbm
0.3
Simulation of multi-dimensional stationary Gaussian processes and fractional Brownian motion.
|
Stein's fractional Brownian motion context. More...
#include <libfbm.hpp>
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 zvec & | getDim () const |
Get the usable dimension of the generated field. | |
const zvec & | getFieldDim () 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. |
Stein's fractional Brownian motion context.
Stein [3] defines fBm as a random process Z with a power-law increment variance:
however, the covariance does not match that of a "standard" fBm. Indeed, for Stein it is actually
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.
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.
H | The Hurst exponent. |
dim | Dimensionality of the field wanted (1D, 2D, 3D, etc.). |
size | Request field of size^dim. |
Rhint | Hint 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. |
mapDim | Expand 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.
|
virtual |
Covariance function.
Implements libfbm::SGPContext.
void libfbm::FBMSteinContext::disablePostProcessing | ( | ) |
|
static |
Map the field dimension into the resulting usable fBm field dimension.
|
inline |
Get the parameter R described in [3].
Definition at line 961 of file libfbm.hpp.
|
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.
Rhint | If equal or greater than 1, return Rhint. |
|
protectedvirtual |
Postprocessor called after field generation.
This is called automatically by Field::generate().
Reimplemented from libfbm::SGPContext.
|
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.