queso-0.53.0
BetaVectorRV.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/GslVector.h>
26 #include <queso/GslMatrix.h>
27 
28 #include <queso/BetaJointPdf.h>
29 #include <queso/BetaVectorRV.h>
30 #include <queso/BetaVectorRealizer.h>
31 
32 namespace QUESO {
33 
34 // Constructor---------------------------------------
35 template<class V, class M>
37  const char* prefix,
38  const VectorSet<V,M>& imageSet,
39  const V& alpha,
40  const V& beta)
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 BetaVectorRV<V,M>::constructor()"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 
50 // begin kemelli 2013-April-22 : --------------------------
51 
52  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&imageSet);
53 
54  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
55  double biggerOfMaxValues = imageBox->maxValues().getMaxValue();
56  double smallerOfMinValues = imageBox->minValues().getMinValue();
57  double biggerOfMinValues = imageBox->minValues().getMaxValue();
58 
59  // Beta dist is defined only in [0,1]
60  if( (smallerOfMinValues < 0) || ( biggerOfMaxValues > 1 ) )
61  {
62  std::cerr << "In BetaVectorRV<V,M>::constructor()\n"
63  << "Beta distribution is defined only in [0, 1].\n"
64  << "The data provided is: \n"
65  << *imageBox
66  << "Sampling will not cover all interval.\n"
67  << std::endl;
68 
69  // if at least one of the min values > 1 then exit
70  queso_require_less_equal_msg(biggerOfMinValues, 1, "invalid input: Beta distribution is only defined in [0, 1], and max(m_minValues)>1");
71  // if at least one of the max values < 0 then exit
72  queso_require_greater_equal_msg(smallerOfMaxValues, 0, "invalid input: Beta distribution is only defined in [0, 1], and min(m_maxValues)<0");
73  }
74  // end kemelli 2013-April-22 --------------------------
75 
76  m_pdf = new BetaJointPdf<V,M>(m_prefix.c_str(),
77  m_imageSet,
78  alpha,
79  beta);
81  m_imageSet,
82  alpha,
83  beta);
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 BetaVectorRV<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 BetaVectorRV<V,M>::print(std::ostream& os) const
108 {
109  os << "BetaVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
110  return;
111 }
112 
113 } // End namespace QUESO
114 
unsigned int displayVerbosity() const
Definition: Environment.C:396
virtual ~BetaVectorRV()
Virtual destructor.
Definition: BetaVectorRV.C:96
A templated class for handling sets.
Definition: VectorSet.h:52
BetaVectorRV(const char *prefix, const VectorSet< V, M > &imageSet, const V &alpha, const V &beta)
Default Constructor.
Definition: BetaVectorRV.C:36
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:117
A templated base class for handling vector RV.
Definition: VectorRV.h:54
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
A class representing a vector RV constructed via Beta distribution.
Definition: BetaVectorRV.h:64
void print(std::ostream &os) const
TODO: Prints the vector RV.
Definition: BetaVectorRV.C:107
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
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:73
A class for handling sampling from a Beta probability density distribution.
const BaseVectorCdf< V, M > * m_unifiedCdf
Definition: VectorRV.h:121
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
A class for handling Beta joint PDFs.
Definition: BetaJointPdf.h:49
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