queso-0.56.1
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 #include <cmath>
28 
29 #include <queso/InfiniteDimensionalMeasureBase.h>
30 #include <queso/InfiniteDimensionalGaussian.h>
31 #include <queso/Environment.h>
32 #include <queso/FunctionBase.h>
33 #include <queso/OperatorBase.h>
34 
35 namespace QUESO {
36 
38  const FullEnvironment& env,
39  const FunctionBase & mean,
40  const OperatorBase & precision,
41  double alpha,
42  double beta)
44  mean(mean),
45  precision(precision),
46  env(env),
47  alpha(alpha),
48  beta(beta)
49 {
50  this->coeffs.resize(this->precision.get_num_converged(), 0.0);
51 }
52 
54 {
55 }
56 
57 SharedPtr<FunctionBase>::Type InfiniteDimensionalGaussian::draw()
58 {
59  unsigned int i;
60 
61  for (i = 0; i < this->precision.get_num_converged(); i++) {
62  (this->coeffs)[i] = env.rngObject()->gaussianSample(this->beta);
63  }
64 
65 #warning We never use the mean?
66 
67 SharedPtr<FunctionBase>::Type f(this->precision.inverse_kl_transform(this->coeffs, this->alpha));
68  return f;
69 }
70 
72 {
73  // This is code repetition, but I'm not quite sure this belongs
74  // in the operator class, because it's useful in the measure
75  return (this->coeffs)[i] / std::pow(this->precision.get_eigenvalue(i), this->alpha / 2.0);
76 }
77 
78 } // End namespace QUESO
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
virtual unsigned int get_num_converged() const =0
Return the number of converged eigenpairs.
virtual SharedPtr< FunctionBase >::Type draw()
Draw from the measure, and then return a shared pointer to the draw.
Abstract base class for operator objects. Operators are assumed to be symmetric and positive-definite...
Definition: OperatorBase.h:45
virtual double get_eigenvalue(unsigned int i) const =0
Return eigenvalue i.
Abstract base class for infinite dimensional measures.
This class sets up the full environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:435
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
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...
Abstract base class for function objects.
Definition: FunctionBase.h:47
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 SharedPtr< FunctionBase >::Type inverse_kl_transform(std::vector< double > &xi, double alpha) const =0
Given coefficients xi, computes the Karhunen-Loeve transform.

Generated on Thu Dec 15 2016 13:23:10 for queso-0.56.1 by  doxygen 1.8.5