queso-0.51.1
JeffreysVectorRealizer.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/JeffreysVectorRealizer.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>& unifiedImageSet)
36  :
37  BaseVectorRealizer<V,M>(((std::string)(prefix)+"gen").c_str(),unifiedImageSet,std::numeric_limits<unsigned int>::max())
38 {
39  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
40  *m_env.subDisplayFile() << "Entering JeffreysVectorRealizer<V,M>::constructor()"
41  << ": prefix = " << m_prefix
42  << std::endl;
43  }
44 
45  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
46  *m_env.subDisplayFile() << "Leaving JeffreysVectorRealizer<V,M>::constructor()"
47  << ": prefix = " << m_prefix
48  << std::endl;
49  }
50 }
51 // Destructor --------------------------------------
52 template<class V, class M>
54 {
55 }
56 // Realization-related methods----------------------
57 template<class V, class M>
58 void
60 {
61  const BoxSubset<V,M>* imageBox = dynamic_cast<const BoxSubset<V,M>* >(&m_unifiedImageSet);
62 
63  if (imageBox == NULL) {
64  queso_error_msg("For JeffreysVectorRealizer<V,M>::realization(), only box images are supported right now");
65  }
66  //take log of Jeffreys bounds to set uniform bounds
67  GslVector logMinValues(imageBox->minValues());
68  for (unsigned int i = 0; i < logMinValues.sizeLocal(); ++i) {
69  if (logMinValues[i] < 0.0) {
70  queso_error_msg("The minimum value for a Jeffreys distribution should be greater than or equal to zero.");
71  }
72  else {
73  logMinValues[i] = std::log(logMinValues[i]);
74  }
75  }
76 
77  GslVector logMaxValues(imageBox->maxValues());
78  for (unsigned int i = 0; i < logMaxValues.sizeLocal(); ++i) {
79  if (logMaxValues[i] <= 0.0) {
80  queso_error_msg("The maximum value for a Jeffreys distribution should be greater than zero.");
81  }
82  else {
83  logMaxValues[i] = std::log(logMaxValues[i]);
84  }
85  }
86 
87  nextValues.cwSetUniform(logMinValues,logMaxValues);
88  for (unsigned int i = 0; i < nextValues.sizeLocal(); ++i) {
89  nextValues[i] = std::exp(nextValues[i]);
90  }
91  return;
92 }
93 
94 } // End namespace QUESO
95 
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
A templated (base) class for handling sampling from vector RVs.
A class for handling sampling from a jeffreys probability density distribution.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
const V & maxValues() const
Vector of the maximum values of the box subset.
Definition: BoxSubset.C:88
JeffreysVectorRealizer(const char *prefix, const VectorSet< V, M > &unifiedImageSet)
Constructor.
Class for vector operations using GSL library.
Definition: GslVector.h:48
#define queso_error_msg(msg)
Definition: asserts.h:91
const BaseEnvironment & m_env
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:41
void realization(V &nextValues) const
Draws a realization.
unsigned int displayVerbosity() const
Definition: Environment.C:436

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