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

Generated on Thu Apr 23 2015 19:26:15 for queso-0.51.1 by  doxygen 1.8.5