queso-0.53.0
GammaVectorRealizer.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 <limits>
26 
27 #include <queso/GammaVectorRealizer.h>
28 #include <queso/GslVector.h>
29 #include <queso/GslMatrix.h>
30 
31 namespace QUESO {
32 
33 // Constructor -------------------------------------
34 template<class V, class M>
36  const char* prefix,
37  const VectorSet<V,M>& unifiedImageSet,
38  const V& a,
39  const V& b)
40  :
41  BaseVectorRealizer<V,M>(((std::string)(prefix)+"gen").c_str(),unifiedImageSet,std::numeric_limits<unsigned int>::max()),
42  m_a(a),
43  m_b(b)
44 {
45  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
46  *m_env.subDisplayFile() << "Entering GammaVectorRealizer<V,M>::constructor()"
47  << ": prefix = " << m_prefix
48  << std::endl;
49  }
50 
51  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
52  *m_env.subDisplayFile() << "Leaving GammaVectorRealizer<V,M>::constructor()"
53  << ": prefix = " << m_prefix
54  << std::endl;
55  }
56 }
57 // Destructor --------------------------------------
58 template<class V, class M>
60 {
61 }
62 // Realization-related methods----------------------
63 template<class V, class M>
64 void
66 {
67  // nextValues.cwSetGamma(m_a,m_b);
68 
69 // begin kemelli 2013-April-22 :
70  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&this->m_unifiedImageSet);
71 // double biggerOfMaxValues = imageBox->maxValues().getMaxValue();
72  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
73  double smallerOfMinValues = imageBox->minValues().getMinValue();
74 
75  // Gamma dist belongs to (0,inf)
76  if( smallerOfMinValues < 0 ) //(biggerOfMinValues < 0) ||
77  {
78  std::cerr << "In GammaVectorRealizer<V,M>::realization()\n"
79  << "Gamma distribution is only defined in (0, infinity).\n"
80  << "The data provided is: \n"
81  << *imageBox
82  << "Sampling will not cover all interval.\n"
83  << std::endl;
84 
85 
86  queso_require_greater_equal_msg(smallerOfMaxValues, 0, "invalid input: Gamma distribution is only defined in (0, infinity), and min(m_maxValues)<0. ");
87 
88 
89  // m_env.worldRank(),
90  // "GammaVectorRealizer<V,M>::realization()",
91  // "invalid input: Gamma distribution is only defined in (0, infinity). ");
92 
93  }
94 
95  // end kemelli 2013-April-22
96 
97  // begin kemelli 2013-April-18 :
98  bool outOfSupport = true;
99  do {
100 
101  nextValues.cwSetGamma(m_a,m_b);
102  outOfSupport = !(this->m_unifiedImageSet.contains(nextValues));
103 
104  } while (outOfSupport);
105 
106  // end kemelli 2013-April-18 :
107 
108  return;
109 }
110 
111 } // End namespace QUESO
112 
unsigned int displayVerbosity() const
Definition: Environment.C:396
A templated class for handling sets.
Definition: VectorSet.h:52
const BaseEnvironment & m_env
A class for handling sampling from a Gamma probability density distribution.
void realization(V &nextValues) const
Draws a realization.
GammaVectorRealizer(const char *prefix, const VectorSet< V, M > &unifiedImageSet, const V &a, const V &b)
Constructor.
const V & maxValues() const
Vector of the maximum values of the box subset.
Definition: BoxSubset.C:79
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
A templated (base) class for handling sampling from vector RVs.
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:73
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:44
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90

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