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

Generated on Thu Apr 23 2015 19:18:34 for queso-0.50.1 by  doxygen 1.8.5