queso-0.51.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/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  UQ_FATAL_TEST_MACRO(smallerOfMaxValues < 0,
69  m_env.worldRank(),
70  "GammaVectorRealizer<V,M>::constructor()",
71  "invalid input: Gamma distribution is only defined in (0, infinity), and min(m_maxValues)<0");
72  }
73 // end kemelli 2013-April-22 --------------------------
74 
75  m_pdf = new GammaJointPdf<V,M>(m_prefix.c_str(),
76  m_imageSet,
77  a,
78  b);
80  m_imageSet,
81  a,
82  b);
83 
84  m_subCdf = NULL; // FIX ME: complete code
85  m_unifiedCdf = NULL; // FIX ME: complete code
86  m_mdf = NULL; // FIX ME: complete code
87 
88  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
89  *m_env.subDisplayFile() << "Leaving GammaVectorRV<V,M>::constructor()"
90  << ": prefix = " << m_prefix
91  << std::endl;
92  }
93 }
94 // Destructor ---------------------------------------
95 template<class V, class M>
97 {
98  delete m_mdf;
99  delete m_unifiedCdf;
100  delete m_subCdf;
101  delete m_realizer;
102  delete m_pdf;
103 }
104 // I/O methods---------------------------------------
105 template <class V, class M>
106 void
107 GammaVectorRV<V,M>::print(std::ostream& os) const
108 {
109  os << "GammaVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
110  return;
111 }
112 
113 } // End namespace QUESO
114 
virtual ~GammaVectorRV()
Virtual destructor.
Definition: GammaVectorRV.C:96
void print(std::ostream &os) const
TODO: Prints the vector RV.
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:118
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
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
A class representing a vector RV constructed via Gamma distribution.
Definition: GammaVectorRV.h:59
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:114
const BaseEnvironment & m_env
Definition: VectorRV.h:112
const V & maxValues() const
Vector of the maximum values of the box subset.
Definition: BoxSubset.C:88
const BaseVectorCdf< V, M > * m_subCdf
Definition: VectorRV.h:117
BaseVectorRealizer< V, M > * m_realizer
Definition: VectorRV.h:116
GammaVectorRV(const char *prefix, const VectorSet< V, M > &imageSet, const V &a, const V &b)
Default Constructor.
Definition: GammaVectorRV.C:36
A class for handling sampling from a Gamma probability density distribution.
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:41
A templated base class for handling vector RV.
Definition: VectorRV.h:51
unsigned int displayVerbosity() const
Definition: Environment.C:436
const BaseVectorMdf< V, M > * m_mdf
Definition: VectorRV.h:119
A class for handling Gamma joint PDFs.
Definition: GammaJointPdf.h:49
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
std::string m_prefix
Definition: VectorRV.h:113
BaseJointPdf< V, M > * m_pdf
Definition: VectorRV.h:115

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