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
364 virtual void subUniformlySampledCdf (
const V& numEvaluationPointsVec,
367 virtual void unifiedUniformlySampledCdf (
const V& numEvaluationPointsVec,
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;
393 virtual void subCdfStacc (
unsigned int initialPos,
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
398 void computeHistCdfstaccKde (
const SequenceStatisticalOptions& statisticalOptions,
399 std::ofstream* passedOfs);
401 void computeStatistics (
const SequenceStatisticalOptions& statisticalOptions,
402 std::ofstream* passedOfs);
404 void computeHistCdfstaccKde (
const SsOptionsValues& statisticalOptions,
405 std::ofstream* passedOfs);
407 void computeStatistics (
const SsOptionsValues& statisticalOptions,
408 std::ofstream* passedOfs);
409 #endif //QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
411 #ifdef UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
412 virtual void subUniformlySampledMdf (
const V& numEvaluationPointsVec,
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
451 virtual void subMeanMonitorAlloc (
unsigned int numberOfMonitorPositions) = 0;
452 virtual void subMeanInter0MonitorAlloc (
unsigned int numberOfMonitorPositions) = 0;
453 virtual void unifiedMeanMonitorAlloc (
unsigned int numberOfMonitorPositions) = 0;
455 virtual void subMeanMonitorRun (
unsigned int monitorPosition,
457 V& subMeanCltStd) = 0;
458 virtual void subMeanInter0MonitorRun (
unsigned int monitorPosition,
459 V& subMeanInter0Mean,
460 V& subMeanInter0Clt95,
461 V& subMeanInter0Empirical90,
463 V& subMeanInter0Max) = 0;
464 virtual void unifiedMeanMonitorRun (
unsigned int monitorPosition,
466 V& unifiedMeanCltStd) = 0;
468 virtual void subMeanMonitorStore (
unsigned int i,
469 unsigned int monitorPosition,
471 const V& subMeanCltStd) = 0;
472 virtual void subMeanInter0MonitorStore (
unsigned int i,
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;
479 virtual void unifiedMeanMonitorStore (
unsigned int i,
480 unsigned int monitorPosition,
482 V& unifiedMeanCltStd) = 0;
484 virtual void subMeanMonitorWrite (std::ofstream& ofs) = 0;
485 virtual void subMeanInter0MonitorWrite (std::ofstream& ofs) = 0;
486 virtual void unifiedMeanMonitorWrite (std::ofstream& ofs) = 0;
488 virtual void subMeanMonitorFree () = 0;
489 virtual void subMeanInter0MonitorFree () = 0;
490 virtual void unifiedMeanMonitorFree () = 0;
492 void computeMeanEvolution (
const SequenceStatisticalOptions& statisticalOptions,
493 std::ofstream* passedOfs);
495 void computeMeanEvolution (
const SsOptionsValues& statisticalOptions,
496 std::ofstream* passedOfs);
499 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
500 void computeBMM (
const SequenceStatisticalOptions& statisticalOptions,
501 const std::vector<unsigned int>& initialPosForStatistics,
502 std::ofstream* passedOfs);
503 void computeFFT (
const SequenceStatisticalOptions& statisticalOptions,
504 const std::vector<unsigned int>& initialPosForStatistics,
505 std::ofstream* passedOfs);
506 void computePSD (
const SequenceStatisticalOptions& statisticalOptions,
507 const std::vector<unsigned int>& initialPosForStatistics,
508 std::ofstream* passedOfs);
509 void computePSDAtZero (
const SequenceStatisticalOptions& statisticalOptions,
510 const std::vector<unsigned int>& initialPosForStatistics,
511 std::ofstream* passedOfs);
512 void computeGeweke (
const SequenceStatisticalOptions& statisticalOptions,
513 const std::vector<unsigned int>& initialPosForStatistics,
514 std::ofstream* passedOfs);
515 void computeMeanStacc (
const SequenceStatisticalOptions& statisticalOptions,
516 const std::vector<unsigned int>& initialPosForStatistics,
517 std::ofstream* passedOfs);
519 void computeBMM (
const SsOptionsValues& statisticalOptions,
520 const std::vector<unsigned int>& initialPosForStatistics,
521 std::ofstream* passedOfs);
522 void computeFFT (
const SsOptionsValues& statisticalOptions,
523 const std::vector<unsigned int>& initialPosForStatistics,
524 std::ofstream* passedOfs);
525 void computePSD (
const SsOptionsValues& statisticalOptions,
526 const std::vector<unsigned int>& initialPosForStatistics,
527 std::ofstream* passedOfs);
528 void computePSDAtZero (
const SsOptionsValues& statisticalOptions,
529 const std::vector<unsigned int>& initialPosForStatistics,
530 std::ofstream* passedOfs);
531 void computeGeweke (
const SsOptionsValues& statisticalOptions,
532 const std::vector<unsigned int>& initialPosForStatistics,
533 std::ofstream* passedOfs);
534 void computeMeanStacc (
const SsOptionsValues& statisticalOptions,
535 const std::vector<unsigned int>& initialPosForStatistics,
536 std::ofstream* passedOfs);
539 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
540 void computeMeanVars (
const SequenceStatisticalOptions& statisticalOptions,
541 std::ofstream* passedOfs,
546 void computeAutoCorrViaDef (
const SequenceStatisticalOptions& statisticalOptions,
547 const std::vector<unsigned int>& initialPosForStatistics,
548 const std::vector<unsigned int>& lagsForCorrs,
549 std::ofstream* passedOfs);
550 void computeAutoCorrViaFFT (
const SequenceStatisticalOptions& statisticalOptions,
551 const std::vector<unsigned int>& initialPosForStatistics,
552 const std::vector<unsigned int>& lagsForCorrs,
553 std::ofstream* passedOfs);
554 void computeCovCorrMatrices (
const SequenceStatisticalOptions& statisticalOptions,
555 std::ofstream* passedOfs);
556 void computeMeanVars (
const SsOptionsValues& statisticalOptions,
557 std::ofstream* passedOfs,
562 void computeAutoCorrViaDef (
const SsOptionsValues& statisticalOptions,
563 const std::vector<unsigned int>& initialPosForStatistics,
564 const std::vector<unsigned int>& lagsForCorrs,
565 std::ofstream* passedOfs);
566 void computeAutoCorrViaFFT (
const SsOptionsValues& statisticalOptions,
567 const std::vector<unsigned int>& initialPosForStatistics,
568 const std::vector<unsigned int>& lagsForCorrs,
569 std::ofstream* passedOfs);
570 void computeCovCorrMatrices (
const SsOptionsValues& statisticalOptions,
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 autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const =0
Calculates the autocovariance. See template specialization.
Class to accommodate arrays of one-dimensional grid.
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-...
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
const V & unifiedMeanPlain() const
Finds the mean value of the unified sequence.
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.
double unifiedPositionsOfMaximum(const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &unifiedPositionsOfMaximum)
Finds the positions where the maximum element occurs in the unified sequence.
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...
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...
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.
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...
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.
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.
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 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...
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 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 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...
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)
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...
const V & subMaxPlain() const
Finds the maximum value of the sub-sequence.
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 ...
BoxSubset< V, M > * m_subBoxPlain
void clear()
Reset the values and the size of the sequence of vectors.
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 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...
virtual void unifiedInterQuantileRange(unsigned int initialPos, V &unifiedIqrVec) const =0
Returns the interquartile range of the values in the unified sequence. See template specialization...
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.
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.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
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 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.
Class to accommodate arrays of one-dimensional tables.
BaseVectorSequence(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
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.
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.
virtual void resetValues(unsigned int initialPos, unsigned int numPos)=0
Reset the values of the sequence. See template specialization.
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
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...
Class representing a subset of a vector space shaped like a hypercube.
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.
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 ~BaseVectorSequence()
Destructor.
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 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...
V * m_subSampleVariancePlain
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.
A class representing a vector space.
virtual unsigned int subSequenceSize() const =0
Size of the sub-sequence of vectors. See template specialization.
virtual double estimateConvBrooksGelman(unsigned int initialPos, unsigned int numPos) const =0
Estimates convergence rate using Brooks & Gelman method. See template specialization.
void setName(const std::string &newName)
Changes the name of the sequence of vectors.
const V & subMeanPlain() const
Finds the mean value of the sub-sequence.
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 erasePositions(unsigned int initialPos, unsigned int numPos)=0
Erase numPos positions in the sequence, starting at position initialPos.
Base class for handling vector and array samples (sequence of vectors or arrays). ...
virtual void autoCorrViaDef(unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const =0
Calculates autocorrelation via definition. See template specialization.
unsigned int unifiedSequenceSize() const
Calculates the size of the unified sequence of vectors.
const V & subMedianPlain() const
Finds the median value of the sub-sequence.
virtual void setPositionValues(unsigned int posId, const V &vec)=0
Set the values in vec at position posId of the sequence. See template specialization.
virtual void subInterQuantileRange(unsigned int initialPos, V &iqrVec) const =0
Returns the interquartile range of the values in the sub-sequence. See template specialization.