queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::ArrayOfSequences< V, M > Class Template Reference

Class for handling array samples (arrays of scalar sequences). More...

#include <ArrayOfSequences.h>

Inheritance diagram for QUESO::ArrayOfSequences< V, M >:
QUESO::BaseVectorSequence< V, M >

Public Member Functions

Constructor/Destructor methods
 ArrayOfSequences (const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
 Default constructor. More...
 
 ~ArrayOfSequences ()
 Destructor. More...
 
Sequence methods
unsigned int subSequenceSize () const
 Size of the sub-sequence of arrays. More...
 
void resizeSequence (unsigned int newSubSequenceSize)
 Resizes the sequence. More...
 
void resetValues (unsigned int initialPos, unsigned int numPos)
 Resets a total of numPos values of the sequence starting at position initialPos. More...
 
void erasePositions (unsigned int initialPos, unsigned int numPos)
 Erases numPos elements of the sequence starting at position initialPos. More...
 
void getPositionValues (unsigned int posId, V &vec) const
 Gets the values of the sequence at position posId and stores them at vec. More...
 
void setPositionValues (unsigned int posId, const V &vec)
 Set the values of vec at position posId of the sequence. More...
 
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 deviation by stdDevVec. More...
 
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 and bVec. More...
 
void mean (unsigned int initialPos, unsigned int numPos, V &meanVec) const
 Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPos. More...
 
void unifiedMean (unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
 Finds the mean value of the unified sequence of numPos positions starting at position initialPos. See template specialization. More...
 
void sampleVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
 Finds the sample variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void unifiedSampleVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
 Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void populationVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &popVec) const
 Finds the population variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void autoCovariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
 Calculates the autocovariance. More...
 
void autoCorrViaDef (unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const
 Calculates autocorrelation via definition. More...
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, unsigned int numSum, V &autoCorrsSumVec) const
 
void minMax (unsigned int initialPos, V &minVec, V &maxVec) const
 Given an initial position initialPos, finds the minimum and the maximum values of the sequence. More...
 
void histogram (unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > &centersForAllBins, std::vector< V * > &quanttsForAllBins) const
 Calculates the histogram of the sequence. More...
 
void interQuantileRange (unsigned int initialPos, V &iqrs) const
 Returns the interquartile range of the values in the sequence. More...
 
void scalesForKDE (unsigned int initialPos, const V &iqrs, unsigned int kdeDimension, V &scales) const
 Selects the scales (bandwidth, scaleVec) for the kernel density estimation, of the sequence. More...
 
void gaussianKDE (const V &evaluationParamVec, V &densityVec) const
 Gaussian kernel for the KDE estimate of the sequence. More...
 
void gaussianKDE (unsigned int initialPos, const V &scales, const std::vector< V * > &evaluationParamVecs, std::vector< V * > &densityVecs) const
 TODO: Gaussian kernel for the KDE of the sequence. More...
 
void writeContents (std::ofstream &ofsvar) const
 Write contents of the chain to a file. More...
 
void unifiedWriteContents (std::ofstream &ofsvar) const
 Writes info of the unified sequence to a file. More...
 
void unifiedWriteContents (const std::string &fileName, const std::string &fileType) const
 Writes info of the unified sequence to a file. More...
 
void unifiedReadContents (const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)
 Reads the unified sequence from a file. More...
 
void select (const std::vector< unsigned int > &idsOfUniquePositions)
 Select positions in the sequence of vectors. More...
 
void filter (unsigned int initialPos, unsigned int spacing)
 Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spacing. More...
 
void extractScalarSeq (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
 Extracts a sequence of scalars of size numPos, from position paramId of the array of sequences. More...
 
void uniformlySampledMdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &mdfGrids, ArrayOfOneDTables< V, M > &mdfValues) const
 
void uniformlySampledCdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &cdfGrids, ArrayOfOneDTables< V, M > &cdfValues) const
 
void bmm (unsigned int initialPos, unsigned int batchLength, V &bmmVec) const
 
void fftForward (unsigned int initialPos, unsigned int fftSize, unsigned int paramId, std::vector< std::complex< double > > &resultData) const
 
void psd (unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, unsigned int paramId, std::vector< double > &psdResult) const
 
void psdAtZero (unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, V &psdVec) const
 
void geweke (unsigned int initialPos, double ratioNa, double ratioNb, V &gewVec) const
 
- Public Member Functions inherited from QUESO::BaseVectorSequence< V, M >
 BaseVectorSequence (const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
 Default constructor. More...
 
virtual ~BaseVectorSequence ()
 Destructor. More...
 
unsigned int unifiedSequenceSize () const
 Calculates the size of the unified sequence of vectors. More...
 
unsigned int vectorSizeLocal () const
 Local dimension (size) of the vector space. More...
 
unsigned int vectorSizeGlobal () const
 Global dimension (size) of the vector space. More...
 
const VectorSpace< V, M > & vectorSpace () const
 Vector space; access to protected attribute VectorSpace<V,M>& m_vectorSpace. More...
 
const std::string & name () const
 Access to protected attribute m_name: name of the sequence of vectors. More...
 
void setName (const std::string &newName)
 Changes the name of the sequence of vectors. More...
 
void clear ()
 Reset the values and the size of the sequence of vectors. More...
 
const V & subMinPlain () const
 Finds the minimum value of the sub-sequence. More...
 
const V & unifiedMinPlain () const
 Finds the minimum value of the unified sequence. More...
 
const V & subMaxPlain () const
 Finds the maximum value of the sub-sequence. More...
 
const V & unifiedMaxPlain () const
 Finds the maximum value of the unified sequence. More...
 
const V & subMeanPlain () const
 Finds the mean value of the sub-sequence. More...
 
const V & unifiedMeanPlain () const
 Finds the mean value of the unified sequence. More...
 
const V & subMedianPlain () const
 Finds the median value of the sub-sequence. More...
 
const V & unifiedMedianPlain () const
 Finds the median value of the unified sequence. More...
 
const V & subSampleVariancePlain () const
 Finds the variance of a sample of the sub-sequence. More...
 
const V & unifiedSampleVariancePlain () const
 Finds the variance of a sample of the unified sequence. More...
 
const BoxSubset< V, M > & subBoxPlain () const
 Finds a box subset of the sub-sequence (given by its min and max values calculated via subMinPlain and subMaxPlain). More...
 
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 calculated via unifiedMinPlain and unifiedMaxPlain). More...
 
void deleteStoredVectors ()
 Deletes all the stored vectors. More...
 
void append (const BaseVectorSequence< V, M > &src, unsigned int initialPos, unsigned int numPos)
 Appends the vector src to this vector. More...
 
double subPositionsOfMaximum (const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &subPositionsOfMaximum)
 Finds the positions where the maximum element occurs in the sub-sequence. More...
 
double unifiedPositionsOfMaximum (const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &unifiedPositionsOfMaximum)
 Finds the positions where the maximum element occurs in the unified sequence. More...
 
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 deviation by stdDevVec. More...
 
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 and bVec. More...
 
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 initialPos. See template specialization. More...
 
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. See template specialization. More...
 
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 initialPos. See template specialization. More...
 
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 initialPos. See template specialization. More...
 
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 initialPos and of mean meanVec. See template specialization. More...
 
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 initialPos and of mean meanVec. See template specialization. More...
 
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 initialPos and of mean meanVec. See template specialization. More...
 
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 position initialPos and of mean meanVec. See template specialization. More...
 
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 at position initialPos. See template specialization. More...
 
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 starting at position initialPos. See template specialization. More...
 
virtual void subHistogram (unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > &centersForAllBins, std::vector< V * > &quanttsForAllBins) const =0
 Calculates the histogram of the sub-sequence. See template specialization. More...
 
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. More...
 
virtual void subInterQuantileRange (unsigned int initialPos, V &iqrVec) const =0
 Returns the interquartile range of the values in the sub-sequence. See template specialization. More...
 
virtual void unifiedInterQuantileRange (unsigned int initialPos, V &unifiedIqrVec) const =0
 Returns the interquartile range of the values in the unified sequence. See template specialization. More...
 
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-sequence. See template specialization. More...
 
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. See template specialization. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual void subWriteContents (unsigned int initialPos, unsigned int numPos, std::ofstream &ofsvar, const std::string &fileType) const =0
 Writes info of the sub-sequence to a file. See template specialization. More...
 
void computeFilterParams (std::ofstream *passedOfs, unsigned int &initialPos, unsigned int &spacing)
 Computes the filtering parameters spacing for the sequence of vectors. More...
 
virtual double estimateConvBrooksGelman (unsigned int initialPos, unsigned int numPos) const =0
 Estimates convergence rate using Brooks & Gelman method. See template specialization. More...
 
virtual void subUniformlySampledCdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &cdfGrids, ArrayOfOneDTables< V, M > &cdfValues) const =0
 
virtual void unifiedUniformlySampledCdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &unifiedCdfGrids, ArrayOfOneDTables< V, M > &unifieddfValues) const =0
 
virtual void meanStacc (unsigned int initialPos, V &meanStaccVec) const =0
 
virtual void subCdfStacc (unsigned int initialPos, const std::vector< V * > &evalPositionsVecs, std::vector< V * > &cdfStaccVecs) const =0
 
void computeHistCdfstaccKde (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeStatistics (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeHistCdfstaccKde (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
void computeStatistics (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
virtual void subUniformlySampledMdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &mdfGrids, ArrayOfOneDTables< V, M > &mdfValues) const =0
 

Private Member Functions

void extractRawData (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
 Extracts the raw data. More...
 

Private Attributes

DistArray< ScalarSequence
< double > * > 
m_scalarSequences
 Sequence of scalars. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::BaseVectorSequence< V, M >
void copy (const BaseVectorSequence< V, M > &src)
 Copies vector sequence src to this. More...
 
virtual void subMeanMonitorAlloc (unsigned int numberOfMonitorPositions)=0
 
virtual void subMeanInter0MonitorAlloc (unsigned int numberOfMonitorPositions)=0
 
virtual void unifiedMeanMonitorAlloc (unsigned int numberOfMonitorPositions)=0
 
virtual void subMeanMonitorRun (unsigned int monitorPosition, V &subMeanVec, V &subMeanCltStd)=0
 
virtual void subMeanInter0MonitorRun (unsigned int monitorPosition, V &subMeanInter0Mean, V &subMeanInter0Clt95, V &subMeanInter0Empirical90, V &subMeanInter0Min, V &subMeanInter0Max)=0
 
virtual void unifiedMeanMonitorRun (unsigned int monitorPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)=0
 
virtual void subMeanMonitorStore (unsigned int i, unsigned int monitorPosition, const V &subMeanVec, const V &subMeanCltStd)=0
 
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
 
virtual void unifiedMeanMonitorStore (unsigned int i, unsigned int monitorPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)=0
 
virtual void subMeanMonitorWrite (std::ofstream &ofs)=0
 
virtual void subMeanInter0MonitorWrite (std::ofstream &ofs)=0
 
virtual void unifiedMeanMonitorWrite (std::ofstream &ofs)=0
 
virtual void subMeanMonitorFree ()=0
 
virtual void subMeanInter0MonitorFree ()=0
 
virtual void unifiedMeanMonitorFree ()=0
 
void computeMeanEvolution (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeMeanEvolution (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
void computeBMM (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)
 
void computePSD (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSDAtZero (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeGeweke (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanStacc (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeBMM (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeFFT (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSD (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSDAtZero (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeGeweke (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanStacc (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanVars (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs, V *subMeanPtr, V *subMedianPtr, V *subSampleVarPtr, V *subPopulVarPtr)
 
void computeAutoCorrViaDef (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeAutoCorrViaFFT (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeCovCorrMatrices (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeMeanVars (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs, V *subMeanPtr, V *subMedianPtr, V *subSampleVarPtr, V *subPopulVarPtr)
 
void computeAutoCorrViaDef (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeAutoCorrViaFFT (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeCovCorrMatrices (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
- Protected Attributes inherited from QUESO::BaseVectorSequence< V, M >
const BaseEnvironmentm_env
 
const VectorSpace< V, M > & m_vectorSpace
 
std::string m_name
 
Fft< double > * m_fftObj
 
V * m_subMinPlain
 
V * m_unifiedMinPlain
 
V * m_subMaxPlain
 
V * m_unifiedMaxPlain
 
V * m_subMeanPlain
 
V * m_unifiedMeanPlain
 
V * m_subMedianPlain
 
V * m_unifiedMedianPlain
 
V * m_subSampleVariancePlain
 
V * m_unifiedSampleVariancePlain
 
BoxSubset< V, M > * m_subBoxPlain
 
BoxSubset< V, M > * m_unifiedBoxPlain
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::ArrayOfSequences< V, M >

Class for handling array samples (arrays of scalar sequences).

This class handles array of sequences (samples) generated by an algorithm, as well as operations that can be carried over them, e.g., calculation of means, correlation and covariance matrices. It is derived from and implements BaseVectorSequence<V,M>.

Definition at line 47 of file ArrayOfSequences.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::ArrayOfSequences< V, M >::ArrayOfSequences ( const VectorSpace< V, M > &  vectorSpace,
unsigned int  subSequenceSize,
const std::string &  name 
)

Default constructor.

Definition at line 32 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::m_env, QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ArrayOfSequences< V, M >::subSequenceSize().

35  : BaseVectorSequence<V,M>(vectorSpace,subSequenceSize,name),
37 {
38 
39  //if (m_env.subDisplayFile()) {
40  // *m_env.subDisplayFile() << "Entering ArrayOfSequences<V,M>::constructor()"
41  // << std::endl;
42  //}
43 
44  //if (m_env.subDisplayFile()) {
45  // *m_env.subDisplayFile() << "In ArrayOfSequences<V,M>::constructor()"
46  // << "\n subSequenceSize = " << subSequenceSize
47  // << "\n m_scalarSequences.MyLength() = " << m_scalarSequences.MyLength()
48  // << std::endl;
49  //}
50 
51  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
52  m_scalarSequences(i,0) = new ScalarSequence<double>(m_env,subSequenceSize);
53  }
54 
55  //if (m_env.subDisplayFile()) {
56  // *m_env.subDisplayFile() << "Leaving ArrayOfSequences<V,M>::constructor()"
57  // << std::endl;
58  //}
59 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
const VectorSpace< V, M > & m_vectorSpace
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace&lt;V,M&gt;&amp; m_vectorSpace.
const BaseEnvironment & m_env
template<class V , class M >
QUESO::ArrayOfSequences< V, M >::~ArrayOfSequences ( )

Destructor.

Definition at line 63 of file ArrayOfSequences.C.

64 {
65  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
66  if (m_scalarSequences(i,0)) delete m_scalarSequences(i,0);
67  }
68 }
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.

Member Function Documentation

template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::autoCorrViaDef ( unsigned int  initialPos,
unsigned int  numPos,
unsigned int  lag,
V &  corrVec 
) const
virtual

Calculates autocorrelation via definition.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 310 of file ArrayOfSequences.C.

314 {
315  V subChainMean (m_vectorSpace.zeroVector());
316  V subChainAutoCovarianceLag0(m_vectorSpace.zeroVector());
317 
318  this->mean(initialPos,
319  numPos,
320  subChainMean);
321  this->autoCovariance(initialPos,
322  numPos,
323  subChainMean,
324  0, // lag
325  subChainAutoCovarianceLag0);
326 
327  this->autoCovariance(initialPos,
328  numPos,
329  subChainMean,
330  lag,
331  corrVec);
332  corrVec /= subChainAutoCovarianceLag0;
333 
334  return;
335 }
void autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
Calculates the autocovariance.
const VectorSpace< V, M > & m_vectorSpace
void mean(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
const std::vector< unsigned int > &  lags,
std::vector< V * > &  corrVecs 
) const
virtual

Calculates autocorrelation via Fast Fourier transforms (FFT). TODO: Implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 338 of file ArrayOfSequences.C.

342 {
343  return;
344 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
unsigned int  numSum,
V &  autoCorrsSumVec 
) const
virtual

Calculates autocorrelation via Fast Fourier transforms (FFT). TODO: Implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 347 of file ArrayOfSequences.C.

References QUESO::ScalarSequence< T >::autoCorrViaFft().

351 {
352 #if 0
353  bool bRC = ((initialPos < this->subSequenceSize()) &&
354  (0 < numPos ) &&
355  ((initialPos+numPos) <= this->subSequenceSize()) &&
356  (autoCorrsSumVec.size() == this->vectorSize() ));
357  queso_require_msg(bRC, "invalid input data");
358 
359  ScalarSequence<double> data(m_env,0);
360 
361  unsigned int numParams = this->vectorSize();
362  for (unsigned int i = 0; i < numParams; ++i) {
363  this->extractScalarSeq(initialPos,
364  1, // spacing
365  numPos,
366  i,
367  data);
368 
369  data.autoCorrViaFft(0,
370  numPos,
371  autoCorrsSumVec[i]);
372  }
373 #endif
374  return;
375 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars of size numPos, from position paramId of the array of sequences...
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::autoCovariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
unsigned int  lag,
V &  covVec 
) const
virtual

Calculates the autocovariance.

The autocovariance is the covariance of a variable with itself at some other time. It is calculated over a sequence of arrays with initial position initialPos, considering numPos positions, a lag of lag, with mean given by meanVec. The results are saved in the output vector covVec/

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 268 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

273 {
274  bool bRC = ((0 <= initialPos ) &&
275  (0 < numPos ) &&
276  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
277  queso_require_msg(bRC, "invalid initial position or number of positions");
278 
279  bRC = (numPos > lag);
280  queso_require_msg(bRC, "lag is too large");
281 
282  bRC = (this->vectorSize() == covVec.size());
283  queso_require_msg(bRC, "incompatible sizes between covVec vector and vectors in sequence");
284 
285  bRC = (this->vectorSize() == meanVec.size());
286  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
287 
288  unsigned int loopSize = numPos - lag;
289  unsigned int finalPosPlus1 = initialPos + loopSize;
290  double doubleLoopSize = (double) loopSize;
291  covVec.cwSet(0.);
292 
293  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
294  for (unsigned int i = 0; i < covVec.size(); ++i) {
295  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
296  double meanValue = meanVec[i];
297  double result = 0;
298  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
299  double diff1 = seq[j] - meanValue;
300  double diff2 = seq[j+lag] - meanValue;
301  result += diff1*diff2;
302  }
303  covVec[i] = result/doubleLoopSize;
304  }
305 
306  return;
307 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::bmm ( unsigned int  initialPos,
unsigned int  batchLength,
V &  bmmVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 678 of file ArrayOfSequences.C.

681 {
682 #if 0
683  V meanOfBatchMeans (*(sequence[0]));
684  V covLag0OfBatchMeans(*(sequence[0]));
685  V covLag1OfBatchMeans(*(sequence[0]));
686 
687  V tmpVector(m_vectorSpace.zeroVector()); // In order to contour the fact that 'batchMeans' is a vector of 'const V*', but needs to be set first
688  for (unsigned int initialPosId = 0; initialPosId < initialPositions.size(); initialPosId++) {
689  for (unsigned int batchLengthId = 0; batchLengthId < batchLengths.size(); batchLengthId++) {
690  unsigned int batchLength = batchLengths[batchLengthId];
691  unsigned int numberOfBatches = (sequence.size() - initialPositions[initialPosId])/batchLength;
692 
693  std::vector<const V* > batchMeans(numberOfBatches,NULL);
694  for (unsigned int batchId = 0; batchId < numberOfBatches; batchId++) {
695  VectorSequenceMean(sequence,
696  initialPositions[initialPosId] + batchId*batchLength,
697  batchLength,
698  tmpVector);
699  batchMeans[batchId] = new V(tmpVector);
700  }
701 
702  VectorSequenceMean(batchMeans,
703  0,
704  batchMeans.size(),
705  meanOfBatchMeans);
706 
707  VectorSequenceAutoCovariance(batchMeans,
708  0,
709  batchMeans.size(),
710  meanOfBatchMeans,
711  0, // lag
712  covLag0OfBatchMeans);
713 
714  VectorSequenceAutoCovariance(batchMeans,
715  0,
716  batchMeans.size(),
717  meanOfBatchMeans,
718  1, // lag
719  covLag0OfBatchMeans);
720 
721  VectorSequenceSampleVariance(batchMeans,
722  0,
723  batchMeans.size(),
724  meanOfBatchMeans,
725  _2dArrayOfBMM(initialPosId,batchLengthId));
726  //_2dArrayOfBMM(initialPosId,batchLengthId) /= (double) batchMeans.size(); // CHECK
727  _2dArrayOfBMM(initialPosId,batchLengthId) *= (double) (sequence.size() - initialPositions[initialPosId]); // CHECK
728 
729  for (unsigned int batchId = 0; batchId < numberOfBatches; batchId++) {
730  if (batchMeans[batchId] != NULL) delete batchMeans[batchId];
731  }
732  }
733  }
734 #endif
735  return;
736 }
const VectorSpace< V, M > & m_vectorSpace
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::erasePositions ( unsigned int  initialPos,
unsigned int  numPos 
)
virtual

Erases numPos elements of the sequence starting at position initialPos.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 106 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::erasePositions().

108 {
109  if (initialPos < this->subSequenceSize()) {
110  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
111  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
112  seq.erasePositions(initialPos,numPos);
113  }
114  }
115 
117 
118  return;
119 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::extractRawData ( unsigned int  initialPos,
unsigned int  spacing,
unsigned int  numPos,
unsigned int  paramId,
std::vector< double > &  rawData 
) const
privatevirtual

Extracts the raw data.

Extracts the data from sequence of array at position paramId, with spacing spacing, and saves is in rawData. The vector rawData will have size numPos. Note that, in fact, spacing = 1.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 622 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

627 {
628  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
629  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(paramId,0));
630 
631  rawData.resize(numPos);
632  if (spacing == 1) {
633  for (unsigned int j = 0; j < numPos; ++j) {
634  rawData[j] = seq[paramId];
635  }
636  }
637  else {
638  for (unsigned int j = 0; j < numPos; ++j) {
639  rawData[j] = seq[paramId];
640  }
641  }
642 
643  return;
644 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::extractScalarSeq ( unsigned int  initialPos,
unsigned int  spacing,
unsigned int  numPos,
unsigned int  paramId,
ScalarSequence< double > &  scalarSeq 
) const
virtual

Extracts a sequence of scalars of size numPos, from position paramId of the array of sequences.

In this method, the parameter initialPos is unused and the parameter spacing is always equal to one

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 596 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ScalarSequence< T >::resizeSequence().

601 {
602  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
603  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(paramId,0));
604 
605  scalarSeq.resizeSequence(numPos);
606  if (spacing == 1) {
607  for (unsigned int j = 0; j < numPos; ++j) {
608  scalarSeq[j] = seq[paramId];
609  }
610  }
611  else {
612  for (unsigned int j = 0; j < numPos; ++j) {
613  scalarSeq[j] = seq[paramId];
614  }
615  }
616 
617  return;
618 }
void resizeSequence(unsigned int newSequenceSize)
Resizes the size of the sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::fftForward ( unsigned int  initialPos,
unsigned int  fftSize,
unsigned int  paramId,
std::vector< std::complex< double > > &  resultData 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 739 of file ArrayOfSequences.C.

743 {
744  return;
745 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::filter ( unsigned int  initialPos,
unsigned int  spacing 
)
virtual

Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spacing.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 589 of file ArrayOfSequences.C.

591 {
592  return;
593 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::gaussianKDE ( const V &  evaluationParamVec,
V &  densityVec 
) const

Gaussian kernel for the KDE estimate of the sequence.

TODO: implement me!

Definition at line 497 of file ArrayOfSequences.C.

499 {
500  return;
501 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::gaussianKDE ( unsigned int  initialPos,
const V &  scales,
const std::vector< V * > &  evaluationParamVecs,
std::vector< V * > &  densityVecs 
) const

TODO: Gaussian kernel for the KDE of the sequence.

Todo:
: implement me! The density estimator will be:

\[ \hat{f}(x) = \frac{1}{nh} \sum_{j=1}^n K\Big(\frac{x-x_j}{h}\Big),\]

where \( K \) is a Gaussian kernel.

Definition at line 504 of file ArrayOfSequences.C.

References QUESO::MiscGaussianDensity().

508 {
509 #if 0
510  unsigned int dataSize = sequence.size() - initialPos;
511  unsigned int numEstimationsPerParam = evaluationParamVecs.size();
512 
513  for (unsigned int j = 0; j < numEstimationsPerParam; ++j) {
514  densityVecs[j] = new V(*(sequence[0]));
515  }
516 
517  unsigned int numParams = sequence[0]->size();
518  for (unsigned int i = 0; i < numParams; ++i) {
519  double scaleInv = 1./scales[i];
520  for (unsigned int j = 0; j < numEstimationsPerParam; ++j) {
521  double x = (*(evaluationParamVecs[j]))[i];
522  double value = 0.;
523  for (unsigned int k = 0; k < dataSize; ++k) {
524  double xk = (*(sequence[initialPos+k]))[i];
525  value += MiscGaussianDensity((x-xk)*scaleInv,0.,1.);
526  }
527  (*(densityVecs[j]))[i] = scaleInv * (value/(double) numEstimationsPerParam);
528  }
529  }
530 
531 #endif
532  return;
533 }
double MiscGaussianDensity(double x, double mu, double sigma)
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::getPositionValues ( unsigned int  posId,
V &  vec 
) const
virtual

Gets the values of the sequence at position posId and stores them at vec.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 122 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

123 {
124  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
125  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
126  vec[i] = (*(tmp->m_scalarSequences(i,0)))[posId];
127  }
128 
129  return;
130 }
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::geweke ( unsigned int  initialPos,
double  ratioNa,
double  ratioNb,
V &  gewVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 791 of file ArrayOfSequences.C.

References QUESO::ScalarSequence< T >::psd().

794 {
795 #if 0
796  for (unsigned int initialPosId = 0; initialPosId < initialPositions.size(); initialPosId++) {
797  unsigned int fullDataSize = sequence.size() - initialPositions[initialPosId];
798  unsigned int dataSizeA = (unsigned int) (((double) fullDataSize) * ratioNa);
799  unsigned int dataSizeB = (unsigned int) (((double) fullDataSize) * ratioNb);
800  unsigned int initialPosA = initialPositions[initialPosId];
801  unsigned int initialPosB = sequence.size() - dataSizeB;
802 
803  V meanA(*(sequence[0]));
804  VectorSequenceMean(sequence,
805  initialPosA,
806  dataSizeA,
807  meanA);
808 
809  V meanB(*(sequence[0]));
810  VectorSequenceMean(sequence,
811  initialPosB,
812  dataSizeB,
813  meanB);
814 
815  unsigned int numParams = sequence[0]->size();
816 
817  V psdVecA(*(sequence[0]));
818  ScalarSequence<double> dataA(dataSizeA,0.);
819  for (unsigned int i = 0; i < numParams; ++i) {
820  for (unsigned int j = 0; j < dataSizeA; ++j) {
821  dataA[j] = (*(sequence[initialPosA+j]))[i];
822  }
823  std::vector<double> psdSequence(0,0.);
824  dataA.psd(8, // numBlocks
825  .5, // hopSizeRatio
826  psdSequence);
827  psdVecA[i] = psdSequence[0];
828  } // for 'i'
829 
830  V psdVecB(*(sequence[0]));
831  ScalarSequence<double> dataB(dataSizeB,0.);
832  for (unsigned int i = 0; i < numParams; ++i) {
833  for (unsigned int j = 0; j < dataSizeB; ++j) {
834  dataB[j] = (*(sequence[initialPosB+j]))[i];
835  }
836  std::vector<double> psdSequence(0,0.);
837  dataB.psd(8, // numBlocks
838  .5, // hopSizeRatio
839  psdSequence);
840  psdVecB[i] = psdSequence[0];
841  } // for 'i'
842 
843  vectorOfGeweke[initialPosId] = new V(*(sequence[0]));
844 
845  double doubleDataSizeA = (double) dataSizeA;
846  double doubleDataSizeB = (double) dataSizeB;
847  for (unsigned int i = 0; i < numParams; ++i) {
848  (*(vectorOfGeweke[initialPosId]))[i] = (meanA[i] - meanB[i])/std::sqrt(psdVecA[i]/doubleDataSizeA + psdVecB[i]/doubleDataSizeB);
849  }
850  }
851 
852 #endif
853  return;
854 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::histogram ( unsigned int  initialPos,
const V &  minVec,
const V &  maxVec,
std::vector< V * > &  centersForAllBins,
std::vector< V * > &  quanttsForAllBins 
) const

Calculates the histogram of the sequence.

TODO: implement me!

Definition at line 393 of file ArrayOfSequences.C.

References QUESO::queso_require_equal_to_msg.

398 {
399 #if 0
400  queso_require_equal_to_msg(centersForAllBins.size(), quanttsForAllBins.size(), "vectors 'centers' and 'quantts' have different sizes");
401 
402  for (unsigned int j = 0; j < quanttsForAllBins.size(); ++j) {
403  centersForAllBins[j] = new V(*(sequence[0]));
404  quanttsForAllBins [j] = new V(*(sequence[0]));
405  }
406 
407  unsigned int dataSize = sequence.size() - initialPos;
408  unsigned int numParams = sequence[0]->size();
409  for (unsigned int i = 0; i < numParams; ++i) {
410  ScalarSequence<double> data(dataSize,0.);
411  for (unsigned int j = 0; j < dataSize; ++j) {
412  data[j] = (*(sequence[initialPos+j]))[i];
413  }
414 
415  std::vector<double> centers(centersForAllBins.size(),0.);
416  std::vector<double> quantts(quanttsForAllBins.size(),0.);
417  data.histogram(minVec[i],
418  maxVec[i],
419  centers,
420  quantts);
421 
422  for (unsigned int j = 0; j < quantts.size(); ++j) {
423  (*(centersForAllBins[j]))[i] = centers[j];
424  (*(quanttsForAllBins[j]))[i] = quantts[j];
425  }
426  }
427 
428 #endif
429  return;
430 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::interQuantileRange ( unsigned int  initialPos,
V &  iqrs 
) const

Returns the interquartile range of the values in the sequence.

TODO: implement me!

Definition at line 433 of file ArrayOfSequences.C.

435 {
436 #if 0
437  unsigned int dataSize = sequence.size() - initialPos;
438 
439  ArrayOfSequences sortedSequence(dataSize,m_vectorSpace.zeroVector());
440  this->sort(initialPos,
441  sortedSequence);
442 
443  unsigned int pos1 = (unsigned int) ( (((double) dataSize) + 1.)*1./4. - 1. );
444  unsigned int pos3 = (unsigned int) ( (((double) dataSize) + 1.)*3./4. - 1. );
445 
446  double fraction1 = (((double) dataSize) + 1.)*1./4. - 1. - ((double) pos1);
447  double fraction3 = (((double) dataSize) + 1.)*3./4. - 1. - ((double) pos3);
448 
449  unsigned int numParams = sequence[0]->size();
450  for (unsigned int i = 0; i < numParams; ++i) {
451  double value1 = (1.-fraction1) * (*sortedSequence[pos1])[i] + fraction1 * (*sortedSequence[pos1+1])[i];
452  double value3 = (1.-fraction3) * (*sortedSequence[pos3])[i] + fraction3 * (*sortedSequence[pos3+1])[i];
453  iqrs[i] = value3 - value1;
454  }
455 
456 #endif
457  return;
458 }
const VectorSpace< V, M > & m_vectorSpace
ArrayOfSequences(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::mean ( unsigned int  initialPos,
unsigned int  numPos,
V &  meanVec 
) const

Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPos.

Definition at line 172 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ScalarSequence< T >::subMeanExtra().

174 {
175  bool bRC = ((0 <= initialPos ) &&
176  (0 < numPos ) &&
177  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
178  queso_require_msg(bRC, "invalid initial position or number of positions");
179 
180  bRC = (this->vectorSize() == meanVec.size());
181  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
182 
183  meanVec.cwSet(0.);
184  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
185  for (unsigned int i = 0; i < meanVec.size(); ++i) {
186  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
187  meanVec[i] = seq.subMeanExtra(initialPos, numPos);
188  }
189 
190  return;
191 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::minMax ( unsigned int  initialPos,
V &  minVec,
V &  maxVec 
) const

Given an initial position initialPos, finds the minimum and the maximum values of the sequence.

Definition at line 378 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ScalarSequence< T >::subMinMaxExtra().

380 {
381  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
382 
383  unsigned int numParams = this->vectorSize();
384  for (unsigned int i = 0; i < numParams; ++i) {
385  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
386  seq.subMinMaxExtra(initialPos,minVec[i],maxVec[i]);
387  }
388 
389  return;
390 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::populationVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  popVec 
) const

Finds the population variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Definition at line 231 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

235 {
236  bool bRC = ((0 <= initialPos ) &&
237  (0 < numPos ) &&
238  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
239  queso_require_msg(bRC, "invalid initial position or number of positions");
240 
241  bRC = (this->vectorSize() == popVec.size());
242  queso_require_msg(bRC, "incompatible sizes between popVec vector and vectors in sequence");
243 
244  bRC = (this->vectorSize() == meanVec.size());
245  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
246 
247  unsigned int loopSize = numPos;
248  unsigned int finalPosPlus1 = initialPos + loopSize;
249  double doubleLoopSize = (double) loopSize;
250  popVec.cwSet(0.);
251 
252  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
253  for (unsigned int i = 0; i < popVec.size(); ++i) {
254  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
255  double tmpMean = meanVec[i];
256  double result = 0.;
257  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
258  double diff = seq[j] - tmpMean;
259  result += diff*diff;
260  }
261  popVec[i] = result/doubleLoopSize;
262  }
263 
264  return;
265 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::psd ( unsigned int  initialPos,
unsigned int  numBlocks,
double  hopSizeRatio,
unsigned int  paramId,
std::vector< double > &  psdResult 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 748 of file ArrayOfSequences.C.

753 {
754  return;
755 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::psdAtZero ( unsigned int  initialPos,
unsigned int  numBlocks,
double  hopSizeRatio,
V &  psdVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 758 of file ArrayOfSequences.C.

References QUESO::ScalarSequence< T >::psd().

762 {
763 #if 0
764  for (unsigned int initialPosId = 0; initialPosId < initialPositions.size(); initialPosId++) {
765  unsigned int dataSize = sequence.size() - initialPositions[initialPosId];
766  ScalarSequence<double> data(dataSize,0.);
767 
768  unsigned int numParams = sequence[0]->size();
769  for (unsigned int i = 0; i < numParams; ++i) {
770  for (unsigned int j = 0; j < dataSize; ++j) {
771  data[j] = (*(sequence[initialPositions[initialPosId]+j]))[i];
772  }
773  for (unsigned int numsOfBlocksId = 0; numsOfBlocksId < numsOfBlocks.size(); numsOfBlocksId++) {
774  unsigned int numBlocks = numsOfBlocks[numsOfBlocksId];
775  std::vector<double> psdSequence(0,0.); // size will be determined by 'ScalarSequencePSD()'
776  data.psd(numBlocks,
777  hopSizeRatio,
778  psdSequence);
779  _2dArrayOfPSDAtZero(initialPosId,numsOfBlocksId)[i] = psdSequence[0];
780  //if (m_env.subDisplayFile()) {
781  // *m_env.subDisplayFile() << "psdSequence[0] = " << psdSequence[0] << std::endl;
782  //}
783  } // for 'numsOfBlocksId'
784  } // for 'i'
785  }
786 #endif
787  return;
788 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::resetValues ( unsigned int  initialPos,
unsigned int  numPos 
)
virtual

Resets a total of numPos values of the sequence starting at position initialPos.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 93 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors().

95 {
96  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
97  m_scalarSequences(i,0)->resetValues(initialPos,numPos);
98  }
99 
101 
102  return;
103 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::resizeSequence ( unsigned int  newSubSequenceSize)
virtual

Resizes the sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 80 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors().

81 {
82  if (newSubSequenceSize != this->subSequenceSize()) {
83  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
84  m_scalarSequences(i,0)->resizeSequence(newSubSequenceSize);
85  }
86  }
87 
89  return;
90 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::sampleVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  samVec 
) const

Finds the sample variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Definition at line 194 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

198 {
199  bool bRC = ((0 <= initialPos ) &&
200  (0 < numPos ) &&
201  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
202  queso_require_msg(bRC, "invalid initial position or number of positions");
203 
204  bRC = (this->vectorSize() == samVec.size());
205  queso_require_msg(bRC, "incompatible sizes between samVec vector and vectors in sequence");
206 
207  bRC = (this->vectorSize() == meanVec.size());
208  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
209 
210  unsigned int loopSize = numPos;
211  unsigned int finalPosPlus1 = initialPos + loopSize;
212  double doubleLoopSize = (double) loopSize;
213  samVec.cwSet(0.);
214 
215  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
216  for (unsigned int i = 0; i < samVec.size(); ++i) {
217  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
218  double tmpMean = meanVec[i];
219  double result = 0.;
220  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
221  double diff = seq[j] - tmpMean;
222  result += diff*diff;
223  }
224  samVec[i] = result/(doubleLoopSize - 1.);
225  }
226 
227  return;
228 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::scalesForKDE ( unsigned int  initialPos,
const V &  iqrs,
unsigned int  kdeDimension,
V &  scales 
) const

Selects the scales (bandwidth, scaleVec) for the kernel density estimation, of the sequence.

TODO: implement me!

Definition at line 461 of file ArrayOfSequences.C.

465 {
466 #if 0
467  unsigned int dataSize = sequence.size() - initialPos;
468 
469  V mean(*(sequence[0]));
470  VectorSequenceMean(sequence,
471  initialPos,
472  dataSize,
473  mean);
474 
475  V samVec(*(sequence[0]));
476  VectorSequenceSampleVariance(sequence,
477  initialPos,
478  dataSize,
479  mean,
480  samVec);
481 
482  unsigned int numParams = sequence[0]->size();
483  for (unsigned int i = 0; i < numParams; ++i) {
484  if (iqrs[i] <= 0.) {
485  scales[i] = 1.06*std::sqrt(samVec[i])/std::pow(dataSize,1./5.);
486  }
487  else {
488  scales[i] = 1.06*std::min(std::sqrt(samVec[i]),iqrs[i]/1.34)/std::pow(dataSize,1./5.);
489  }
490  }
491 
492 #endif
493  return;
494 }
void mean(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::select ( const std::vector< unsigned int > &  idsOfUniquePositions)
virtual

Select positions in the sequence of vectors.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 582 of file ArrayOfSequences.C.

584 {
585  return;
586 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::setGaussian ( const V &  meanVec,
const V &  stdDevVec 
)

Sets the values of the sequence as a Gaussian distribution of mean given by meanVec and standard deviation by stdDevVec.

This routine deletes all stored computed vectors

Definition at line 146 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::setGaussian().

147 {
148  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
149  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
150  seq.setGaussian(meanVec[i],stdDevVec[i]);
151  }
152 
154 
155  return;
156 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::setPositionValues ( unsigned int  posId,
const V &  vec 
)
virtual

Set the values of vec at position posId of the sequence.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 133 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors().

134 {
135  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
136  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
137  seq[posId] = vec[i];
138  }
139 
141 
142  return;
143 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::setUniform ( const V &  aVec,
const V &  bVec 
)

Sets the values of the sequence as a uniform distribution between the values given by vectors aVec and bVec.

This routine deletes all stored computed vectors

Definition at line 159 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::setUniform().

160 {
161  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
162  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
163  seq.setUniform(aVec[i],bVec[i]);
164  }
165 
167 
168  return;
169 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
unsigned int QUESO::ArrayOfSequences< V, M >::subSequenceSize ( ) const
virtual

Size of the sub-sequence of arrays.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 72 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

Referenced by QUESO::ArrayOfSequences< V, M >::ArrayOfSequences().

73 {
74  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
75 
76  return tmp->m_scalarSequences(0,0)->subSequenceSize();
77 }
template<class V = GslVector, class M = GslMatrix>
void QUESO::ArrayOfSequences< V, M >::unifiedMean ( unsigned int  initialPos,
unsigned int  numPos,
V &  unifiedMeanVec 
) const

Finds the mean value of the unified sequence of numPos positions starting at position initialPos. See template specialization.

template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedReadContents ( const std::string &  fileName,
const std::string &  fileType,
const unsigned int  subSequenceSize 
)
virtual

Reads the unified sequence from a file.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 573 of file ArrayOfSequences.C.

576 {
577  queso_not_implemented();
578  return;
579 }
template<class V = GslVector, class M = GslMatrix>
void QUESO::ArrayOfSequences< V, M >::unifiedSampleVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  samVec 
) const

Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec.

template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedWriteContents ( std::ofstream &  ofsvar) const

Writes info of the unified sequence to a file.

TODO: implement me!

Definition at line 558 of file ArrayOfSequences.C.

559 {
560  queso_not_implemented();
561  return;
562 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedWriteContents ( const std::string &  fileName,
const std::string &  fileType 
) const
virtual

Writes info of the unified sequence to a file.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 565 of file ArrayOfSequences.C.

567 {
568  queso_not_implemented();
569  return;
570 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::uniformlySampledCdf ( const V &  numEvaluationPointsVec,
ArrayOfOneDGrids< V, M > &  cdfGrids,
ArrayOfOneDTables< V, M > &  cdfValues 
) const

Definition at line 649 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, QUESO::ArrayOfOneDTables< V, M >::setOneDTable(), QUESO::ArrayOfOneDGrids< V, M >::setUniformGrids(), and QUESO::ScalarSequence< T >::subUniformlySampledCdf().

653 {
654  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
655  V minCdfValues(m_vectorSpace.zeroVector());
656  V maxCdfValues(m_vectorSpace.zeroVector());
657  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
658  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
659 
660  unsigned int numEvaluationPoints = (unsigned int) numEvaluationPointsVec[i];
661  std::vector<double> aCdf(0);
662  seq.subUniformlySampledCdf(numEvaluationPoints,
663  minCdfValues[i],
664  maxCdfValues[i],
665  aCdf);
666  cdfValues.setOneDTable(i,aCdf);
667  }
668  cdfGrids.setUniformGrids(numEvaluationPointsVec,
669  minCdfValues,
670  maxCdfValues);
671 
672  return;
673 }
const VectorSpace< V, M > & m_vectorSpace
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V = GslVector, class M = GslMatrix>
void QUESO::ArrayOfSequences< V, M >::uniformlySampledMdf ( const V &  numEvaluationPointsVec,
ArrayOfOneDGrids< V, M > &  mdfGrids,
ArrayOfOneDTables< V, M > &  mdfValues 
) const
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::writeContents ( std::ofstream &  ofsvar) const

Write contents of the chain to a file.

Definition at line 536 of file ArrayOfSequences.C.

537 {
538  // Write chain
539  ofsvar << m_name << "_sub" << m_env.subIdString() << " = zeros(" << this->subSequenceSize()
540  << "," << this->vectorSize()
541  << ");"
542  << std::endl;
543  ofsvar << m_name << "_sub" << m_env.subIdString() << " = [";
544 
545  V tmpVec(m_vectorSpace.zeroVector());
546  unsigned int chainSize = this->subSequenceSize();
547  for (unsigned int j = 0; j < chainSize; ++j) {
548  this->getPositionValues(j,tmpVec);
549  ofsvar << tmpVec
550  << std::endl;
551  }
552  ofsvar << "];\n";
553 
554  return;
555 }
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
const VectorSpace< V, M > & m_vectorSpace
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
Definition: Environment.C:348
void getPositionValues(unsigned int posId, V &vec) const
Gets the values of the sequence at position posId and stores them at vec.
const BaseEnvironment & m_env

Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:48:58 for queso-0.57.1 by  doxygen 1.8.5