25 #ifndef UQ_VECTOR_SEQUENCE_H
26 #define UQ_VECTOR_SEQUENCE_H
28 #undef UQ_CODE_HAS_MONITORS
30 #include <queso/VectorSpace.h>
31 #include <queso/BoxSubset.h>
32 #include <queso/ScalarSequence.h>
33 #include <queso/SequenceStatisticalOptions.h>
34 #include <queso/ArrayOfOneDGrids.h>
35 #include <queso/ArrayOfOneDTables.h>
36 #include <queso/2dArrayOfStuff.h>
55 template <
class V = GslVector,
class M = GslMatrix>
64 const std::string&
name);
90 const std::string&
name ()
const;
93 void setName (
const std::string& newName);
144 unsigned int initialPos,
145 unsigned int numPos);
167 virtual void resizeSequence (
unsigned int newSubSequenceSize) = 0;
171 virtual void resetValues (
unsigned int initialPos,
unsigned int numPos) = 0;
175 virtual void erasePositions (
unsigned int initialPos,
unsigned int numPos) = 0;
187 void setGaussian (
const V& meanVec,
const V& stdDevVec);
191 void setUniform (
const V& aVec,
const V& bVec );
196 V& meanVec)
const = 0;
201 V& unifiedMeanVec)
const = 0;
205 V& medianVec)
const = 0;
208 unsigned int localNumPos,
209 V& unifiedMedianVec)
const = 0;
214 V& samVec)
const = 0;
218 const V& unifiedMeanVec,
219 V& unifiedSamVec)
const = 0;
224 V& popVec)
const = 0;
228 const V& unifiedMeanVec,
229 V& unifiedPopVec)
const = 0;
240 V& covVec)
const = 0;
245 V& corrVec)
const = 0;
249 const std::vector<unsigned int>& lags,
250 std::vector<V*>& corrVecs)
const = 0;
255 V& autoCorrsSumVec)
const = 0;
262 V& maxVec)
const = 0;
267 V& unifiedMaxVec)
const = 0;
277 std::vector<V*>& centersForAllBins,
278 std::vector<V*>& quanttsForAllBins)
const = 0;
281 const V& unifiedMinVec,
282 const V& unifiedMaxVec,
283 std::vector<V*>& unifiedCentersForAllBins,
284 std::vector<V*>& unifiedQuanttsForAllBins)
const = 0;
288 V& iqrVec)
const = 0;
291 V& unifiedIqrVec)
const = 0;
304 unsigned int kdeDimension,
305 V& scaleVec)
const = 0;
308 const V& unifiedIqrVec,
309 unsigned int kdeDimension,
310 V& unifiedScaleVec)
const = 0;
318 const std::vector<V*>& evaluationParamVecs,
319 std::vector<V*>& densityVecs)
const = 0;
322 const V& unifiedScaleVec,
323 const std::vector<V*>& unifiedEvaluationParamVecs,
324 std::vector<V*>& unifiedDensityVecs)
const = 0;
328 const std::string& fileName,
329 const std::string& fileType,
330 const std::set<unsigned int>& allowedSubEnvIds)
const = 0;
334 std::ofstream& ofsvar,
335 const std::string& fileType)
const = 0;
338 const std::string& fileType)
const = 0;
341 const std::string& fileType,
342 const unsigned int subSequenceSize) = 0;
344 virtual void select (
const std::vector<unsigned int>& idsOfUniquePositions) = 0;
347 virtual void filter (
unsigned int initialPos,
348 unsigned int spacing) = 0;
351 unsigned int & initialPos,
352 unsigned int & spacing);
355 unsigned int numPos)
const = 0;
358 unsigned int spacing,
360 unsigned int paramId,
363 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
370 virtual void bmm (
unsigned int initialPos,
371 unsigned int batchLength,
372 V& bmmVec)
const = 0;
373 virtual void fftForward (
unsigned int initialPos,
374 unsigned int fftSize,
375 unsigned int paramId,
376 std::vector<std::complex<double> >& fftResult)
const = 0;
378 virtual void psd (
unsigned int initialPos,
379 unsigned int numBlocks,
381 unsigned int paramId,
382 std::vector<double>& psdResult)
const = 0;
383 virtual void psdAtZero (
unsigned int initialPos,
384 unsigned int numBlocks,
386 V& psdVec)
const = 0;
387 virtual void geweke (
unsigned int initialPos,
390 V& gewVec)
const = 0;
391 virtual void meanStacc (
unsigned int initialPos,
392 V& meanStaccVec)
const = 0;
394 const std::vector<V*>& evalPositionsVecs, std::vector<V*>& cdfStaccVecs)
const = 0;
395 #endif //QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
397 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
399 std::ofstream* passedOfs);
402 std::ofstream* passedOfs);
405 std::ofstream* passedOfs);
408 std::ofstream* passedOfs);
409 #endif //QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
411 #ifdef UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
415 #endif //UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
426 unsigned int spacing,
428 unsigned int paramId,
429 std::vector<double>& rawData)
const = 0;
450 #ifdef UQ_CODE_HAS_MONITORS
457 V& subMeanCltStd) = 0;
459 V& subMeanInter0Mean,
460 V& subMeanInter0Clt95,
461 V& subMeanInter0Empirical90,
463 V& subMeanInter0Max) = 0;
466 V& unifiedMeanCltStd) = 0;
469 unsigned int monitorPosition,
471 const V& subMeanCltStd) = 0;
473 unsigned int monitorPosition,
474 const V& subMeanInter0Mean,
475 const V& subMeanInter0Clt95,
476 const V& subMeanInter0Empirical90,
477 const V& subMeanInter0Min,
478 const V& subMeanInter0Max) = 0;
480 unsigned int monitorPosition,
482 V& unifiedMeanCltStd) = 0;
493 std::ofstream* passedOfs);
496 std::ofstream* passedOfs);
499 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
501 const std::vector<unsigned int>& initialPosForStatistics,
502 std::ofstream* passedOfs);
504 const std::vector<unsigned int>& initialPosForStatistics,
505 std::ofstream* passedOfs);
507 const std::vector<unsigned int>& initialPosForStatistics,
508 std::ofstream* passedOfs);
510 const std::vector<unsigned int>& initialPosForStatistics,
511 std::ofstream* passedOfs);
513 const std::vector<unsigned int>& initialPosForStatistics,
514 std::ofstream* passedOfs);
516 const std::vector<unsigned int>& initialPosForStatistics,
517 std::ofstream* passedOfs);
520 const std::vector<unsigned int>& initialPosForStatistics,
521 std::ofstream* passedOfs);
523 const std::vector<unsigned int>& initialPosForStatistics,
524 std::ofstream* passedOfs);
526 const std::vector<unsigned int>& initialPosForStatistics,
527 std::ofstream* passedOfs);
529 const std::vector<unsigned int>& initialPosForStatistics,
530 std::ofstream* passedOfs);
532 const std::vector<unsigned int>& initialPosForStatistics,
533 std::ofstream* passedOfs);
535 const std::vector<unsigned int>& initialPosForStatistics,
536 std::ofstream* passedOfs);
539 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
541 std::ofstream* passedOfs,
547 const std::vector<unsigned int>& initialPosForStatistics,
548 const std::vector<unsigned int>& lagsForCorrs,
549 std::ofstream* passedOfs);
551 const std::vector<unsigned int>& initialPosForStatistics,
552 const std::vector<unsigned int>& lagsForCorrs,
553 std::ofstream* passedOfs);
555 std::ofstream* passedOfs);
557 std::ofstream* passedOfs,
563 const std::vector<unsigned int>& initialPosForStatistics,
564 const std::vector<unsigned int>& lagsForCorrs,
565 std::ofstream* passedOfs);
567 const std::vector<unsigned int>& initialPosForStatistics,
568 const std::vector<unsigned int>& lagsForCorrs,
569 std::ofstream* passedOfs);
571 std::ofstream* passedOfs);
580 template <
class P_V,
class P_M,
class Q_V,
class Q_M>
585 unsigned int subNumSamples,
591 #endif // UQ_VECTOR_SEQUENCE_H
virtual void subMeanMonitorWrite(std::ofstream &ofs)=0
virtual void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const =0
Writes info of the sub-sequence to a file. See template specialization.
Class to accommodate arrays of one-dimensional grid.
virtual void unifiedMedianExtra(unsigned int initialPos, unsigned int localNumPos, V &unifiedMedianVec) const =0
Finds the median value of the unified sequence, considering numPos positions starting at position ini...
void copy(const BaseVectorSequence< V, M > &src)
Copies vector sequence src to this.
virtual void subMeanExtra(unsigned int initialPos, unsigned int numPos, V &meanVec) const =0
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
virtual void autoCorrViaFft(unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const =0
Calculates autocorrelation via Fast Fourier transforms (FFT). See template specialization.
virtual void unifiedMinMaxExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMinVec, V &unifiedMaxVec) const =0
Finds the minimum and the maximum values of the unified sequence, considering numPos positions starti...
virtual unsigned int subSequenceSize() const =0
Size of the sub-sequence of vectors. See template specialization.
virtual void fftForward(unsigned int initialPos, unsigned int fftSize, unsigned int paramId, std::vector< std::complex< double > > &fftResult) const =0
virtual void subMeanMonitorFree()=0
virtual void unifiedMeanMonitorStore(unsigned int i, unsigned int monitorPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)=0
void computeAutoCorrViaDef(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
virtual void geweke(unsigned int initialPos, double ratioNa, double ratioNb, V &gewVec) const =0
virtual void subUniformlySampledCdf(const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &cdfGrids, ArrayOfOneDTables< V, M > &cdfValues) const =0
A class representing a vector space.
void setName(const std::string &newName)
Changes the name of the sequence of vectors.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
const V & subMeanPlain() const
Finds the mean value of the sub-sequence.
virtual void erasePositions(unsigned int initialPos, unsigned int numPos)=0
Erase numPos positions in the sequence, starting at position initialPos.
void computeBMM(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
A templated class that stores statistical options (optionally read from an input file) ...
unsigned int unifiedSequenceSize() const
Calculates the size of the unified sequence of vectors.
virtual void subMinMaxExtra(unsigned int initialPos, unsigned int numPos, V &minVec, V &maxVec) const =0
Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting a...
virtual void subInterQuantileRange(unsigned int initialPos, V &iqrVec) const =0
Returns the interquartile range of the values in the sub-sequence. See template specialization.
virtual void autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const =0
Calculates the autocovariance. See template specialization.
virtual void unifiedMeanExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const =0
Finds the mean value of the unified sequence of numPos positions starting at position initialPos...
virtual void subMeanInter0MonitorStore(unsigned int i, unsigned int monitorPosition, const V &subMeanInter0Mean, const V &subMeanInter0Clt95, const V &subMeanInter0Empirical90, const V &subMeanInter0Min, const V &subMeanInter0Max)=0
void computeStatistics(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
Class to accommodate arrays of one-dimensional tables.
virtual void unifiedSampleVarianceExtra(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const =0
Finds the sample variance of the unified sequence, considering numPos positions starting at position ...
void clear()
Reset the values and the size of the sequence of vectors.
virtual void subSampleVarianceExtra(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const =0
Finds the sample variance of the sub-sequence, considering numPos positions starting at position init...
void append(const BaseVectorSequence< V, M > &src, unsigned int initialPos, unsigned int numPos)
Appends the vector src to this vector.
const V & unifiedSampleVariancePlain() const
Finds the variance of a sample of the unified sequence.
virtual void unifiedMeanMonitorFree()=0
void setUniform(const V &aVec, const V &bVec)
Sets the values of the sequence as a uniform distribution between the values given by vectors aVec an...
virtual void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const =0
Extracts a sequence of scalars of size numPos, starting at position initialPos, given spacing spacing...
const V & subSampleVariancePlain() const
Finds the variance of a sample of the sub-sequence.
void computeFilterParams(std::ofstream *passedOfs, unsigned int &initialPos, unsigned int &spacing)
Computes the filtering parameters spacing for the sequence of vectors.
unsigned int vectorSizeGlobal() const
Global dimension (size) of the vector space.
virtual void unifiedMeanMonitorWrite(std::ofstream &ofs)=0
virtual void subMeanMonitorRun(unsigned int monitorPosition, V &subMeanVec, V &subMeanCltStd)=0
void deleteStoredVectors()
Deletes all the stored vectors.
virtual void unifiedScalesForKde(unsigned int initialPos, const V &unifiedIqrVec, unsigned int kdeDimension, V &unifiedScaleVec) const =0
Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence...
double subPositionsOfMaximum(const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &subPositionsOfMaximum)
Finds the positions where the maximum element occurs in the sub-sequence.
virtual void subGaussian1dKde(unsigned int initialPos, const V &scaleVec, const std::vector< V * > &evaluationParamVecs, std::vector< V * > &densityVecs) const =0
Gaussian kernel for the KDE estimate of the sub-sequence. See template specialization.
void computeGeweke(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
virtual void unifiedPopulationVariance(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedPopVec) const =0
Finds the population variance of the unified-sequence, considering numPos positions starting at posit...
virtual void meanStacc(unsigned int initialPos, V &meanStaccVec) const =0
void computeCovCorrMatrices(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
virtual void unifiedMeanMonitorAlloc(unsigned int numberOfMonitorPositions)=0
void computeMeanEvolution(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
virtual void unifiedWriteContents(const std::string &fileName, const std::string &fileType) const =0
Writes info of the unified sequence to a file. See template specialization.
V * m_unifiedSampleVariancePlain
const VectorSpace< V, M > & m_vectorSpace
BoxSubset< V, M > * m_unifiedBoxPlain
const V & unifiedMedianPlain() const
Finds the median value of the unified sequence.
virtual void resetValues(unsigned int initialPos, unsigned int numPos)=0
Reset the values of the sequence. See template specialization.
virtual void subMeanInter0MonitorFree()=0
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
Class representing a subset of a vector space shaped like a hypercube.
virtual void subPopulationVariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &popVec) const =0
Finds the population variance of the sub-sequence, considering numPos positions starting at position ...
virtual void bmm(unsigned int initialPos, unsigned int batchLength, V &bmmVec) const =0
Base class for handling vector and array samples (sequence of vectors or arrays). ...
virtual void getPositionValues(unsigned int posId, V &vec) const =0
Gets the values of the sequence at position posId and stores them at vec. See template specialization...
void computeHistCdfstaccKde(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
void computePSDAtZero(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
void computeFFT(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
const V & subMaxPlain() const
Finds the maximum value of the sub-sequence.
virtual void resizeSequence(unsigned int newSubSequenceSize)=0
Resize the sequence. See template specialization.
virtual void select(const std::vector< unsigned int > &idsOfUniquePositions)=0
Select positions in the sequence of vectors. See template specialization.
BoxSubset< V, M > * m_subBoxPlain
const BoxSubset< V, M > & subBoxPlain() const
Finds a box subset of the sub-sequence (given by its min and max values calculated via subMinPlain an...
virtual void unifiedReadContents(const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)=0
Reads info of the unified sequence from a file. See template specialization.
virtual ~BaseVectorSequence()
Destructor.
virtual void subUniformlySampledMdf(const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &mdfGrids, ArrayOfOneDTables< V, M > &mdfValues) const =0
void computeMeanVars(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs, V *subMeanPtr, V *subMedianPtr, V *subSampleVarPtr, V *subPopulVarPtr)
void computeMeanStacc(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
virtual void unifiedInterQuantileRange(unsigned int initialPos, V &unifiedIqrVec) const =0
Returns the interquartile range of the values in the unified sequence. See template specialization...
void setGaussian(const V &meanVec, const V &stdDevVec)
Sets the values of the sequence as a Gaussian distribution of mean given by meanVec and standard devi...
virtual void subMeanInter0MonitorWrite(std::ofstream &ofs)=0
V * m_subSampleVariancePlain
virtual void unifiedMeanMonitorRun(unsigned int monitorPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)=0
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace<V,M>& m_vectorSpace.
const V & unifiedMinPlain() const
Finds the minimum value of the unified sequence.
const V & subMinPlain() const
Finds the minimum value of the sub-sequence.
virtual void subMeanMonitorAlloc(unsigned int numberOfMonitorPositions)=0
virtual void subMeanInter0MonitorRun(unsigned int monitorPosition, V &subMeanInter0Mean, V &subMeanInter0Clt95, V &subMeanInter0Empirical90, V &subMeanInter0Min, V &subMeanInter0Max)=0
virtual double estimateConvBrooksGelman(unsigned int initialPos, unsigned int numPos) const =0
Estimates convergence rate using Brooks & Gelman method. See template specialization.
virtual void filter(unsigned int initialPos, unsigned int spacing)=0
Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spaci...
virtual void unifiedHistogram(unsigned int initialPos, const V &unifiedMinVec, const V &unifiedMaxVec, std::vector< V * > &unifiedCentersForAllBins, std::vector< V * > &unifiedQuanttsForAllBins) const =0
Calculates the histogram of the unified sequence. See template specialization.
virtual void subCdfStacc(unsigned int initialPos, const std::vector< V * > &evalPositionsVecs, std::vector< V * > &cdfStaccVecs) const =0
virtual void autoCorrViaDef(unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const =0
Calculates autocorrelation via definition. See template specialization.
virtual void subMeanMonitorStore(unsigned int i, unsigned int monitorPosition, const V &subMeanVec, const V &subMeanCltStd)=0
const V & subMedianPlain() const
Finds the median value of the sub-sequence.
void computePSD(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
virtual void subHistogram(unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > ¢ersForAllBins, std::vector< V * > &quanttsForAllBins) const =0
Calculates the histogram of the sub-sequence. See template specialization.
virtual void setPositionValues(unsigned int posId, const V &vec)=0
Set the values in vec at position posId of the sequence. See template specialization.
BaseVectorSequence(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
virtual void subScalesForKde(unsigned int initialPos, const V &iqrVec, unsigned int kdeDimension, V &scaleVec) const =0
Selects the scales (bandwidth, scaleVec) for the kernel density estimation, considering only the sub-...
virtual void extractRawData(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const =0
Extracts the raw data. See template specialization.
const V & unifiedMaxPlain() const
Finds the maximum value of the unified sequence.
virtual void subMedianExtra(unsigned int initialPos, unsigned int numPos, V &medianVec) const =0
Finds the median value of the sub-sequence, considering numPos positions starting at position initial...
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
virtual void unifiedGaussian1dKde(unsigned int initialPos, const V &unifiedScaleVec, const std::vector< V * > &unifiedEvaluationParamVecs, std::vector< V * > &unifiedDensityVecs) const =0
Gaussian kernel for the KDE estimate of the unified sequence. See template specialization.
const BaseEnvironment & m_env
virtual void subMeanInter0MonitorAlloc(unsigned int numberOfMonitorPositions)=0
const V & unifiedMeanPlain() const
Finds the mean value of the unified sequence.
virtual void psdAtZero(unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, V &psdVec) const =0
virtual void psd(unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, unsigned int paramId, std::vector< double > &psdResult) const =0
virtual void unifiedUniformlySampledCdf(const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &unifiedCdfGrids, ArrayOfOneDTables< V, M > &unifieddfValues) const =0
void computeAutoCorrViaFFT(const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
double unifiedPositionsOfMaximum(const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &unifiedPositionsOfMaximum)
Finds the positions where the maximum element occurs in the unified sequence.
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)
const BoxSubset< V, M > & unifiedBoxPlain() const
Finds a box subset of the unified-sequence (given by the min and max values of the unified sequence c...
A templated class that stores default statistical options for a sequence of vectors, e.g. a Markov chain, a Monte Carlo input sequence, or a Monte Carlo output sequence.