GPLIB++
MTSampleGenerator.h
Go to the documentation of this file.
1 #ifndef MTSAMPLEGENERATOR_H_
2 #define MTSAMPLEGENERATOR_H_
3 #include <boost/function.hpp>
4 #include <boost/random/lagged_fibonacci.hpp>
5 #include <boost/random/normal_distribution.hpp>
6 #include <boost/random/variate_generator.hpp>
7 #include <complex>
8 #include "MTTensor.h"
9 
10 namespace gplib
11  {
12 
13  /** \addtogroup statistics Statistical methods */
14  /* @{ */
15 
16  //! Generate random elements of a calculated quantity for MT impedance data
17  /*! This class is used for error analysis of MT data using the Bootstrap or Jacknife method.
18  * The constructor takes a pointer to a member function of MTTensor f, a Tensor element Z and an errorlevel
19  * and generates random samples f(Z) within the errorlevel for the impedance.
20  * Each call to operator() yields a new sample
21  */
23  {
24  private:
25  boost::lagged_fibonacci607 generator;
26  boost::normal_distribution<> Zxxr_dist;
27  boost::normal_distribution<> Zxxi_dist;
28  boost::normal_distribution<> Zxyr_dist;
29  boost::normal_distribution<> Zxyi_dist;
30  boost::normal_distribution<> Zyxr_dist;
31  boost::normal_distribution<> Zyxi_dist;
32  boost::normal_distribution<> Zyyr_dist;
33  boost::normal_distribution<> Zyyi_dist;
34 
35  boost::variate_generator<boost::lagged_fibonacci607&,
36  boost::normal_distribution<> > Zxxr;
37  boost::variate_generator<boost::lagged_fibonacci607&,
38  boost::normal_distribution<> > Zxxi;
39  boost::variate_generator<boost::lagged_fibonacci607&,
40  boost::normal_distribution<> > Zxyr;
41  boost::variate_generator<boost::lagged_fibonacci607&,
42  boost::normal_distribution<> > Zxyi;
43  boost::variate_generator<boost::lagged_fibonacci607&,
44  boost::normal_distribution<> > Zyxr;
45  boost::variate_generator<boost::lagged_fibonacci607&,
46  boost::normal_distribution<> > Zyxi;
47  boost::variate_generator<boost::lagged_fibonacci607&,
48  boost::normal_distribution<> > Zyyr;
49  boost::variate_generator<boost::lagged_fibonacci607&,
50  boost::normal_distribution<> > Zyyi;
51  boost::function<double(const MTTensor*)> func;
52  MTTensor Data;
53  public:
54  //! The constructor needs a pointer to a member function of MTTensor that returns a double, an impedance element and an errolevel for all elements
55  /*! For example MTSampleGenerator(&MTTensor::GetRhoxy,DistData) creates a distribution of Zxy apparent resistivity
56  * values that is purely based on the impedance errors in DistData, if an errorlevel was specified this
57  * would be the error floor.*/
58  MTSampleGenerator(boost::function<double(const MTTensor*)> f,
59  const MTTensor &Z, const double errorlevel = 0.0);
60  //! each call to operator() returns a new random sample
61  double operator()();
62  virtual ~MTSampleGenerator();
63  };
64  /* @} */
65  }
66 #endif /*MTSAMPLEGENERATOR_H_*/
MTSampleGenerator(boost::function< double(const MTTensor *)> f, const MTTensor &Z, const double errorlevel=0.0)
The constructor needs a pointer to a member function of MTTensor that returns a double, an impedance element and an errolevel for all elements.
void f(vector< double > &v1, vector< double > &v2, vector< double > &v3, vector< double > &v4)
Definition: perftest.cpp:17
Generate random elements of a calculated quantity for MT impedance data.
double operator()()
each call to operator() returns a new random sample
Stores MT-Tensor components at a single frequency, calculates derived quantities. ...
Definition: MTTensor.h:16