queso-0.53.0
InfiniteDimensionalGaussian.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <memory>
26 #include <vector>
27 
28 #include <boost/shared_ptr.hpp>
29 
30 #include <queso/InfiniteDimensionalMeasureBase.h>
31 #include <queso/InfiniteDimensionalGaussian.h>
32 #include <queso/Environment.h>
33 #include <queso/FunctionBase.h>
34 #include <queso/OperatorBase.h>
35 
36 namespace QUESO {
37 
39  const FullEnvironment& env,
40  const FunctionBase & mean,
41  const OperatorBase & precision,
42  double alpha,
43  double beta)
45  mean(mean),
46  precision(precision),
47  env(env),
48  alpha(alpha),
49  beta(beta)
50 {
51  this->coeffs.resize(this->precision.get_num_converged(), 0.0);
52 }
53 
55 {
56 }
57 
58 boost::shared_ptr<FunctionBase> InfiniteDimensionalGaussian::draw()
59 {
60  unsigned int i;
61 
62  for (i = 0; i < this->precision.get_num_converged(); i++) {
63  (this->coeffs)[i] = env.rngObject()->gaussianSample(this->beta);
64  }
65 
66  boost::shared_ptr<FunctionBase> f(this->precision.inverse_kl_transform(this->coeffs, this->alpha));
67  return f;
68 }
69 
71 {
72  // This is code repetition, but I'm not quite sure this belongs
73  // in the operator class, because it's useful in the measure
74  return (this->coeffs)[i] / pow(this->precision.get_eigenvalue(i), this->alpha / 2.0);
75 }
76 
77 } // End namespace QUESO
Abstract base class for function objects.
Definition: FunctionBase.h:46
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
virtual boost::shared_ptr< FunctionBase > draw()
Draw from the measure, and then return a shared pointer to the draw.
InfiniteDimensionalGaussian(const FullEnvironment &env, const FunctionBase &mean, const OperatorBase &precision, double alpha, double beta)
Construct a Gaussian with mean mean, precision operator precision. alpha controls regularity of draws...
This class sets up the full environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:416
Abstract base class for infinite dimensional measures.
virtual double get_eigenvalue(unsigned int i) const =0
Return eigenvalue i.
virtual boost::shared_ptr< FunctionBase > inverse_kl_transform(std::vector< double > &xi, double alpha) const =0
Given coefficients xi, computes the Karhunen-Loeve transform.
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
Abstract base class for operator objects. Operators are assumed to be symmetric and positive-definite...
Definition: OperatorBase.h:45
virtual double get_kl_coefficient(unsigned int i) const
Return coefficient i of the KL expansion of the current draw. Must be called after draw() ...
virtual unsigned int get_num_converged() const =0
Return the number of converged eigenpairs.

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5