queso-0.53.0
GammaVectorRV.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 <queso/GammaVectorRV.h>
26 #include <queso/GammaVectorRealizer.h>
27 #include <queso/GammaJointPdf.h>
28 #include <queso/GslVector.h>
29 #include <queso/GslMatrix.h>
30 
31 namespace QUESO {
32 
33 // Constructor---------------------------------------
34 // TODO: Check: the constructor receives imageSet, but uses m_imageSet to assign m_pdf and m_realizer. (Kemelli 2013/4/22)
35 template<class V, class M>
37  const char* prefix,
38  const VectorSet<V,M>& imageSet,
39  const V& a,
40  const V& b)
41  :
42  BaseVectorRV<V,M>(((std::string)(prefix)+"uni").c_str(),imageSet)
43 {
44  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
45  *m_env.subDisplayFile() << "Entering GammaVectorRV<V,M>::constructor()"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 
50 // begin kemelli 2013-April-22 --------------------------
51 // better to check for the parameter values in the constructor,
52 // rather than in GammaVectorRealizer<V,M>::realization
53 
54  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&imageSet);
55  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
56  double smallerOfMinValues = imageBox->minValues().getMinValue();
57 
58  // Gamma dist is defined only in (0,inf)
59  if( smallerOfMinValues < 0 )
60  {
61  std::cerr << "In GammaVectorRV<V,M>::constructor()\n"
62  << "Gamma distribution is only defined in (0, infinity).\n"
63  << "The data provided is: \n"
64  << *imageBox
65  << "Sampling will not cover all interval.\n"
66  << std::endl;
67 
68  queso_require_greater_equal_msg(smallerOfMaxValues, 0, "invalid input: Gamma distribution is only defined in (0, infinity), and min(m_maxValues)<0");
69  }
70 // end kemelli 2013-April-22 --------------------------
71 
72  m_pdf = new GammaJointPdf<V,M>(m_prefix.c_str(),
73  m_imageSet,
74  a,
75  b);
77  m_imageSet,
78  a,
79  b);
80 
81  m_subCdf = NULL; // FIX ME: complete code
82  m_unifiedCdf = NULL; // FIX ME: complete code
83  m_mdf = NULL; // FIX ME: complete code
84 
85  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
86  *m_env.subDisplayFile() << "Leaving GammaVectorRV<V,M>::constructor()"
87  << ": prefix = " << m_prefix
88  << std::endl;
89  }
90 }
91 // Destructor ---------------------------------------
92 template<class V, class M>
94 {
95  delete m_mdf;
96  delete m_unifiedCdf;
97  delete m_subCdf;
98  delete m_realizer;
99  delete m_pdf;
100 }
101 // I/O methods---------------------------------------
102 template <class V, class M>
103 void
104 GammaVectorRV<V,M>::print(std::ostream& os) const
105 {
106  os << "GammaVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
107  return;
108 }
109 
110 } // End namespace QUESO
111 
unsigned int displayVerbosity() const
Definition: Environment.C:396
A templated class for handling sets.
Definition: VectorSet.h:52
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:117
A class representing a vector RV constructed via Gamma distribution.
Definition: GammaVectorRV.h:62
A templated base class for handling vector RV.
Definition: VectorRV.h:54
A class for handling sampling from a Gamma probability density distribution.
GammaVectorRV(const char *prefix, const VectorSet< V, M > &imageSet, const V &a, const V &b)
Default Constructor.
Definition: GammaVectorRV.C:36
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:118
std::string m_prefix
Definition: VectorRV.h:116
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
virtual ~GammaVectorRV()
Virtual destructor.
Definition: GammaVectorRV.C:93
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:73
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:121
A class for handling Gamma joint PDFs.
Definition: GammaJointPdf.h:52
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:44
const BaseEnvironment & m_env
Definition: VectorRV.h:115
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:122
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90
void print(std::ostream &os) const
TODO: Prints the vector RV.
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:120
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:119

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