Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MonteCarloTransform.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003, 2004 (see file CONTACTS for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef _MonteCarloTransform_hh_
26 #define _MonteCarloTransform_hh_
27 
28 #include <MathAlgo/UncertaintyTransformBase.hh>
29 #include <Base/Math/Random.hh>
30 
31 #include <vector>
32 
33 namespace BIAS {
34 
35  template <class T> class BIASMathBase_EXPORT Matrix;
36  template <class T> class BIASMathBase_EXPORT Vector;
37 
38  /** @class MonteCarloTransform
39  * @ingroup g_mathalgo
40  @brief monte carlo propagation of uncertainty
41 
42  @author woelk 11/2006 */
43  class BIASMathAlgo_EXPORT MonteCarloTransform
45  {
46  public:
48 
49  virtual ~MonteCarloTransform();
50 
51  /** @brief computes the Monte Carlo approximation of the
52  transformations of the mean and the associated covariance for the
53  point transformation Transform_().
54  @returns 0 on success
55  -1 when transformation of mean failed
56  +1 when transformation of sigma point failed */
57  int Transform(const Vector<double>& src_mean,
58  const Matrix<double>& src_cov,
59  Vector<double>& dst_mean, Matrix<double>& dst_cov) const;
60 
61  int Transform(const Vector<double>& src_mean,
62  const Matrix<double>& src_cov,
63  std::vector<Vector<double> >& dst_samples) const;
64 
65  void Skew(const std::vector<Vector<double> >& dst_samples,
66  double skewnness) const;
67 
68  /** Sets the number of samples per dimension */
69  inline void SetNumSamplesPerDimension(const int num)
70  { NumSamplesPerDimension_ = num; }
71 
72  inline void SetUseQuasiRandomNumbers(const bool uqrn)
73  { UseQuasiRandomNumbers_ = uqrn; }
74 
75  /** switch gauss/uniform distribution */
76  inline void SetUniformDistribution(const bool uqrn)
77  { uniformDistribution_ = uqrn; }
78 
79  protected:
80 
82 
84 
85  /// set to true if you want to sample uniform instead of gauss
87 
88  /** @brief implements a point transformation
89  @returns 0 on success */
90  virtual int Transform_(const Vector<double>& src,
91  Vector<double>& dst) const = 0;
92 
93  /** computes src_mean.Size()* NumSamplesPerDimension_ samples drawn
94  from multidiemsional normal distribution with first two moments
95  src_mean and src_cov */
96  int GetSamples_(const Vector<double>& src_mean,
97  const Matrix<double>& src_cov,
98  std::vector<Vector<double> >& src_samples) const;
99 
100  }; // class
101 
102 } // namespace
103 
104 #endif // _MonteCarloTransform_hh_
void SetUseQuasiRandomNumbers(const bool uqrn)
void SetNumSamplesPerDimension(const int num)
Sets the number of samples per dimension.
void SetUniformDistribution(const bool uqrn)
switch gauss/uniform distribution
class BIASMathBase_EXPORT Matrix
Definition: Operators.hh:37
monte carlo propagation of uncertainty
base class for all uncertainty transforms
class BIASMathBase_EXPORT Vector
bool uniformDistribution_
set to true if you want to sample uniform instead of gauss