25 #include <queso/VectorRV.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
29 #include <queso/Defines.h>
30 #include <gsl/gsl_sf_psi.h>
35 template<
class V,
class M>
40 m_env (imageSet.env()),
41 m_prefix ((std::string)(prefix)+
"rv_"),
42 m_imageSet (imageSet),
62 template<
class V,
class M>
73 template <
class V,
class M>
80 template<
class V,
class M>
87 template<
class V,
class M>
96 template<
class V,
class M>
105 template<
class V,
class M>
114 template<
class V,
class M>
120 return *m_unifiedCdf;
123 template<
class V,
class M>
134 template <
class V,
class M>
144 unsigned int k = UQ_INFTH_ANN_KNN;
145 double eps = UQ_INFTH_ANN_EPS;
149 unsigned int dim = this->imageSet().vectorSpace().dimGlobal();
153 unsigned int N = this->realizer().subPeriod();
155 N = UQ_INFTH_ANN_NO_SMP;
160 dists =
new double[N];
163 V smpRV( this->imageSet().vectorSpace().zeroVector() );
164 for(
unsigned int i = 0; i < N; i++ ) {
166 this->realizer().realization( smpRV );
168 for(
unsigned int j = 0; j <
dim; j++ ) {
169 data[ i ][ j ] = smpRV[ j ];
175 distANN_XY( data, data, dists, dim, dim, N, N, k+1, eps );
180 double sum_log_dist = 0.0;
181 for(
unsigned int i = 0; i < N; i++ ) {
182 if( dists[ i ] > 0 ) {
183 sum_log_dist += log( 2.0*dists[ i ] );
186 ENT_est = - gsl_sf_psi_int( k ) + gsl_sf_psi_int( N ) + (double)dim / (
double)N * sum_log_dist;
194 #endif // QUESO_HAS_ANN
199 template <
class P_V,
class P_M,
class Q_V,
class Q_M>
204 unsigned int localNumSamples,
217 queso_require_msg(!((numRows != pqCovMatrix.numRows()) || (numCols != pqCovMatrix.numCols())),
"inconsistent dimensions for covariance matrix");
219 queso_require_msg(!((numRows != pqCorrMatrix.numRows()) || (numCols != pqCorrMatrix.numCols())),
"inconsistent dimensions for correlation matrix");
233 for (
unsigned int k = 0; k < localNumSamples; ++
k) {
235 localWorkingPSeq.setPositionValues(k,tmpP);
238 localWorkingQSeq.setPositionValues(k,tmpQ);
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
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)
const BaseVectorCdf< V, M > & unifiedCdf() const
Finds the Cumulative Distribution Function of this vector RV, considering the unified sequence of dat...
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
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.
const BaseEnvironment & m_env
const V & zeroVector() const
Returns a vector filled with zeros.
const BaseVectorMdf< V, M > & mdf() const
Finds the Marginal Density Function of this vector RV; access to private attribute m_mdf...
virtual ~BaseVectorRV()
Virtual destructor.
A templated (base) class for handling joint PDFs.
virtual void realization(V &nextValues) const =0
Performs a realization (sample) from a probability density function. See template specialization...
DLL_API void annDeallocPts(ANNpointArray &pa)
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
DLL_API ANNpointArray annAllocPts(int n, int dim)
A templated (base) class for handling CDFs of vector functions.
A templated class for handling sets.
const BaseEnvironment & env() const
QUESO environment; access to private attribute m_env.
BaseVectorRV(const char *prefix, const VectorSet< V, M > &imageSet)
Constructor.
A templated (base) class for handling sampling from vector RVs.
unsigned int displayVerbosity() const
#define queso_require_msg(asserted, msg)
const BaseVectorCdf< V, M > & subCdf() const
Finds the Cumulative Distribution Function of this vector RV, considering only the sub-sequence of da...
const BaseVectorRealizer< V, M > & realizer() const
Finds a realization (sample) of the PDF of this vector RV; access to private attribute m_realizer...
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
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)
unsigned int numOfProcsForStorage() const
Returns total number of processes.
A templated (base) class for handling MDFs of vector functions.