naive_metropolis Class Template Reference

#include <naive_metropolis.h>

Inheritance diagram for naive_metropolis:

mcarlo_inte multi_inte

Detailed Description

template<class param_t, class func_t, class rng_t, class vec_t, class alloc_vec_t>
class naive_metropolis< param_t, func_t, rng_t, vec_t, alloc_vec_t >

Naive metropolis monte carlo integration.

Very experimental.

This returns the ratio of n-dimensional integrals

\[ I = \frac{\int f(\vec{x}) \exp\left[-\beta~w(\vec{x})\right] d \vec{x}} {\int \exp\left[-\beta~w(\vec{x})\right] d \vec{x}} \]

for function $ f $ specified in func and $ w $ specified in weight.

A "Metropolis step" (or simply a "step") is defined by the following procedure: The step $ \vec{x}_0 \rightarrow \vec{x}_1 $ is accepted if

\[ w(\vec{x}_1)<w_(\vec{x}_0) \]

or if

\[ e^{-\beta \left[w(\vec{x}_1)-w_(\vec{x}_0)\right]}>r \]

where $ r $ is a uniform random number $ [0,1) $ newly generated for each step.

nstart steps are taken initially to ensure the first point is created with the correct probability. Afterwards, the average value of the function is stored over niter steps. This average value is computed nblock times to get an overall average and an estimate of the uncertainity.

Todo:
Talk about how accurate this is with $ \beta $ .
Todo:
Redo statistics, talk about how many times the integral is evaluated.
Todo:
Offer an option of giving more results than just the final averange and error?
Minimization

There is a connection between integration over functions of this type and minimization. The expression

\[ \lim_{T \rightarrow 0} \frac{\int_{x=a}^{x=b} f(x) e^{-f(x)/T}} {\int_{x=a}^{x=b} e^{-f(x)/T}} \]

gives the minimum of the function $ f(x) $ in the region $ x \in (a,b) $ .

Definition at line 88 of file naive_metropolis.h.


Public Member Functions

virtual int minteg_err (func_t &func, func_t &energy, size_t ndim, const vec_t &a, const vec_t &b, const double beta, double &value, double &err, param_t &pa)
 Calculate the integral returning result in value.
virtual int minteg_array (func_t &func, func_t &energy, size_t ndim, const vec_t &a, const vec_t &b, const double beta, vec_t &results, param_t &pa)
 Calculate the integral returning result in value.

Data Fields

rng_t rng
unsigned long int niter
 The number of iterations (default 10000).
unsigned long int nstart
 The number of warm-up iterations (default 1000).
unsigned long int nblock
 Number of blocks (default 10).

Member Function Documentation

virtual int minteg_err ( func_t &  func,
func_t &  energy,
size_t  ndim,
const vec_t &  a,
const vec_t &  b,
const double  beta,
double &  value,
double &  err,
param_t &  pa 
) [inline, virtual]

Calculate the integral returning result in value.

Calculates the integral given the functions func and weight over the region specified by a and b, both of side ndim. The value of $ \beta $ is specified in beta, and the result is returned in value, with the uncertainty given in err.

Definition at line 113 of file naive_metropolis.h.

virtual int minteg_array ( func_t &  func,
func_t &  energy,
size_t  ndim,
const vec_t &  a,
const vec_t &  b,
const double  beta,
vec_t &  results,
param_t &  pa 
) [inline, virtual]

Calculate the integral returning result in value.

Calculates the integral given the functions func and weight over the region specified by a and b, both of side ndim. The value of $ \beta $ is specified in beta, and the result is returned in value, with the uncertainty given in err.

Definition at line 192 of file naive_metropolis.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page