25 #include <queso/VectorRV.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
32 template<
class V,
class M>
37 m_env (imageSet.env()),
38 m_prefix ((std::string)(prefix)+
"rv_"),
39 m_imageSet (imageSet),
59 template<
class V,
class M>
70 template <
class V,
class M>
77 template<
class V,
class M>
84 template<
class V,
class M>
90 "BaseVectorRV<V,M>::pdf()",
96 template<
class V,
class M>
102 (std::string)(
"BaseVectorRV<V,M>::realizer(), prefix=")+m_prefix,
103 "m_realizer is NULL");
108 template<
class V,
class M>
114 (std::string)(
"BaseVectorRV<V,M>::subCdf(), prefix=")+m_prefix,
120 template<
class V,
class M>
126 (std::string)(
"BaseVectorRV<V,M>::unifiedCdf(), prefix=")+m_prefix,
127 "m_unifiedCdf is NULL");
129 return *m_unifiedCdf;
132 template<
class V,
class M>
138 (std::string)(
"BaseVectorRV<V,M>::mdf(), prefix=")+m_prefix,
146 template <
class V,
class M>
156 unsigned int k = UQ_INFTH_ANN_KNN;
157 double eps = UQ_INFTH_ANN_EPS;
161 unsigned int dim = this->imageSet().vectorSpace().dimGlobal();
165 unsigned int N = this->realizer().subPeriod();
167 N = UQ_INFTH_ANN_NO_SMP;
171 data = annAllocPts(N,dim);
172 dists =
new double[N];
175 V smpRV( this->imageSet().vectorSpace().zeroVector() );
176 for(
unsigned int i = 0; i < N; i++ ) {
178 this->realizer().realization( smpRV );
180 for(
unsigned int j = 0; j < dim; j++ ) {
181 data[ i ][ j ] = smpRV[ j ];
187 distANN_XY( data, data, dists, dim, dim, N, N, k+1, eps );
192 double sum_log_dist = 0.0;
193 for(
unsigned int i = 0; i < N; i++ ) {
194 if( dists[ i ] > 0 ) {
195 sum_log_dist += log( 2.0*dists[ i ] );
198 ENT_est = - gsl_sf_psi_int( k ) + gsl_sf_psi_int( N ) + (double)dim / (
double)N * sum_log_dist;
202 annDeallocPts( data );
206 #endif // QUESO_HAS_ANN
211 template <
class P_V,
class P_M,
class Q_V,
class Q_M>
216 unsigned int localNumSamples,
228 "ComputeCovCorrMatricesBetweenVectorRvs()",
229 "parallel vectors not supported yet");
234 UQ_FATAL_TEST_MACRO((numRows != pqCovMatrix.numRows()) || (numCols != pqCovMatrix.numCols()),
236 "ComputeCovCorrMatricesBetweenVectorRvs()",
237 "inconsistent dimensions for covariance matrix");
239 UQ_FATAL_TEST_MACRO((numRows != pqCorrMatrix.numRows()) || (numCols != pqCorrMatrix.numCols()),
241 "ComputeCorrelationBetweenVectorRvs()",
242 "inconsistent dimensions for correlation matrix");
246 "ComputeCovCorrMatricesBetweenVectorRvs()",
247 "localNumSamples is too large");
259 for (
unsigned int k = 0; k < localNumSamples; ++k) {
261 localWorkingPSeq.setPositionValues(k,tmpP);
264 localWorkingQSeq.setPositionValues(k,tmpQ);
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
A templated (base) class for handling MDFs of vector functions.
const BaseVectorRealizer< V, M > & realizer() const
Finds a realization (sample) of the PDF of this vector RV; access to private attribute m_realizer...
int worldRank() const
Returns the process world rank.
A templated class for handling sets.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
void ComputeCovCorrMatricesBetweenVectorSequences(const BaseVectorSequence< P_V, P_M > &subPSeq, const BaseVectorSequence< Q_V, Q_M > &subQSeq, unsigned int subNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
void ComputeCovCorrMatricesBetweenVectorRvs(const BaseVectorRV< P_V, P_M > ¶mRv, const BaseVectorRV< Q_V, Q_M > &qoiRv, unsigned int localNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
const V & zeroVector() const
Returns a vector filled with zeros.
unsigned int numOfProcsForStorage() const
Returns total number of processes.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
const BaseVectorCdf< V, M > & unifiedCdf() const
Finds the Cumulative Distribution Function of this vector RV, considering the unified sequence of dat...
const BaseJointPdf< V, M > & pdf() const
Posterior Density Function of the vector RV; access to private attribute m_pdf.
A templated base class for handling vector RV.
A templated (base) class for handling joint PDFs.
const BaseEnvironment & m_env
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
const BaseVectorCdf< V, M > & subCdf() const
Finds the Cumulative Distribution Function of this vector RV, considering only the sub-sequence of da...
virtual void realization(V &nextValues) const =0
Performs a realization (sample) from a probability density function. See template specialization...
A templated (base) class for handling sampling from vector RVs.
const BaseVectorMdf< V, M > & mdf() const
Finds the Mass Density Function of this vector RV; access to private attribute m_mdf.
unsigned int displayVerbosity() const
virtual ~BaseVectorRV()
Virtual destructor.
A templated (base) class for handling CDFs of vector functions.
Class for handling vector samples (sequence of vectors).
const BaseEnvironment & env() const
QUESO environment; access to private attribute m_env.
BaseVectorRV(const char *prefix, const VectorSet< V, M > &imageSet)
Constructor.