queso-0.50.1
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,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/BetaVectorRV.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>& imageSet,
36  const V& alpha,
37  const V& beta)
38  :
39  BaseVectorRV<V,M>(((std::string)(prefix)+"uni").c_str(),imageSet)
40 {
41  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
42  *m_env.subDisplayFile() << "Entering BetaVectorRV<V,M>::constructor()"
43  << ": prefix = " << m_prefix
44  << std::endl;
45  }
46 
47 // begin kemelli 2013-April-22 : --------------------------
48 
49  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&imageSet);
50 
51  double smallerOfMaxValues = imageBox->maxValues().getMinValue();
52  double biggerOfMaxValues = imageBox->maxValues().getMaxValue();
53  double smallerOfMinValues = imageBox->minValues().getMinValue();
54  double biggerOfMinValues = imageBox->minValues().getMaxValue();
55 
56  // Beta dist is defined only in [0,1]
57  if( (smallerOfMinValues < 0) || ( biggerOfMaxValues > 1 ) )
58  {
59  std::cerr << "In BetaVectorRV<V,M>::constructor()\n"
60  << "Beta distribution is defined only in [0, 1].\n"
61  << "The data provided is: \n"
62  << *imageBox
63  << "Sampling will not cover all interval.\n"
64  << std::endl;
65 
66  // if at least one of the min values > 1 then exit
67  UQ_FATAL_TEST_MACRO(biggerOfMinValues > 1,
68  m_env.worldRank(),
69  "In BetaVectorRV<V,M>::constructor()",
70  "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  UQ_FATAL_TEST_MACRO(smallerOfMaxValues < 0, //biggerOfMaxValues
73  m_env.worldRank(),
74  "In BetaVectorRV<V,M>::constructor()",
75  "invalid input: Beta distribution is only defined in [0, 1], and min(m_maxValues)<0");
76  }
77  // end kemelli 2013-April-22 --------------------------
78 
79  m_pdf = new BetaJointPdf<V,M>(m_prefix.c_str(),
80  m_imageSet,
81  alpha,
82  beta);
84  m_imageSet,
85  alpha,
86  beta);
87  m_subCdf = NULL; // FIX ME: complete code
88  m_unifiedCdf = NULL; // FIX ME: complete code
89  m_mdf = NULL; // FIX ME: complete code
90 
91  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
92  *m_env.subDisplayFile() << "Leaving BetaVectorRV<V,M>::constructor()"
93  << ": prefix = " << m_prefix
94  << std::endl;
95  }
96 }
97 // Destructor ---------------------------------------
98 template<class V, class M>
100 {
101  delete m_mdf;
102  delete m_unifiedCdf;
103  delete m_subCdf;
104  delete m_realizer;
105  delete m_pdf;
106 }
107 // I/O methods---------------------------------------
108 template <class V, class M>
109 void
110 BetaVectorRV<V,M>::print(std::ostream& os) const
111 {
112  os << "BetaVectorRV<V,M>::print() says, 'Please implement me.'" << std::endl;
113  return;
114 }
115 
116 } // End namespace QUESO
117 
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
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
const VectorSet< V, M > & m_imageSet
Definition: VectorRV.h:132
A class representing a vector RV constructed via Beta distribution.
Definition: BetaVectorRV.h:61
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
virtual ~BetaVectorRV()
Virtual destructor.
Definition: BetaVectorRV.C:99
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
BetaVectorRV(const char *prefix, const VectorSet< V, M > &imageSet, const V &alpha, const V &beta)
Default Constructor.
Definition: BetaVectorRV.C:33
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:82
A class for handling sampling from a Beta probability density distribution.
void print(std::ostream &os) const
TODO: Prints the vector RV.
Definition: BetaVectorRV.C:110
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 Beta joint PDFs.
Definition: BetaJointPdf.h:49

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