queso-0.53.0
ArrayOfSequences.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_ARRAY_OF_SEQUENCES_H
26 #define UQ_ARRAY_OF_SEQUENCES_H
27 
28 #include <queso/VectorSequence.h>
29 
30 namespace QUESO {
31 
32 class GslVector;
33 class GslMatrix;
34 
46 template <class V = GslVector, class M = GslMatrix>
48 {
49 public:
51 
54  unsigned int subSequenceSize,
55  const std::string& name);
59 
61 
62  unsigned int subSequenceSize () const;
64 
66  void resizeSequence (unsigned int newSubSequenceSize);
67 
69 
70  void resetValues (unsigned int initialPos, unsigned int numPos);
71 
73 
74  void erasePositions (unsigned int initialPos, unsigned int numPos);
75 
77  void getPositionValues (unsigned int posId, V& vec) const;
78 
80 
81  void setPositionValues (unsigned int posId, const V& vec);
82 
84 
85  void setGaussian (const V& meanVec, const V& stdDevVec);
86 
88 
89  void setUniform (const V& aVec, const V& bVec );
90 
92  void mean (unsigned int initialPos,
93  unsigned int numPos,
94  V& meanVec) const;
96  // TODO not implemented.
97  void unifiedMean (unsigned int initialPos,
98  unsigned int numPos,
99  V& unifiedMeanVec) const;
101  void sampleVariance (unsigned int initialPos,
102  unsigned int numPos,
103  const V& meanVec,
104  V& samVec) const;
106  // TODO not implemented.
107  void unifiedSampleVariance(unsigned int initialPos,
108  unsigned int numPos,
109  const V& meanVec,
110  V& samVec) const;
112  void populationVariance (unsigned int initialPos,
113  unsigned int numPos,
114  const V& meanVec,
115  V& popVec) const;
117 
121  void autoCovariance (unsigned int initialPos,
122  unsigned int numPos,
123  const V& meanVec,
124  unsigned int lag,
125  V& covVec) const;
126 
128  void autoCorrViaDef (unsigned int initialPos,
129  unsigned int numPos,
130  unsigned int lag,
131  V& corrVec) const;
134  void autoCorrViaFft (unsigned int initialPos,
135  unsigned int numPos,
136  const std::vector<unsigned int>& lags,
137  std::vector<V*>& corrVecs) const;
138 
141  void autoCorrViaFft (unsigned int initialPos,
142  unsigned int numPos,
143  unsigned int numSum,
144  V& autoCorrsSumVec) const;
146  void minMax (unsigned int initialPos,
147  V& minVec,
148  V& maxVec) const;
150 
151  void histogram (unsigned int initialPos,
152  const V& minVec,
153  const V& maxVec,
154  std::vector<V*>& centersForAllBins,
155  std::vector<V*>& quanttsForAllBins) const;
156 
158 
159  void interQuantileRange (unsigned int initialPos,
160  V& iqrs) const;
161 
163 
164  void scalesForKDE (unsigned int initialPos,
165  const V& iqrs,
166  unsigned int kdeDimension,
167  V& scales) const;
169 
170  void gaussianKDE (const V& evaluationParamVec,
171  V& densityVec) const;
173 
177  void gaussianKDE (unsigned int initialPos,
178  const V& scales,
179  const std::vector<V*>& evaluationParamVecs,
180  std::vector<V*>& densityVecs) const;
182  void writeContents (std::ofstream& ofsvar) const;
183 
185 
186  void unifiedWriteContents (std::ofstream& ofsvar) const;
187 
189 
190  void unifiedWriteContents (const std::string& fileName,
191  const std::string& fileType) const;
192 
194 
195  void unifiedReadContents (const std::string& fileName,
196  const std::string& fileType,
197  const unsigned int subSequenceSize);
198 
200 
201  void select (const std::vector<unsigned int>& idsOfUniquePositions);
202 
204 
205  void filter (unsigned int initialPos,
206  unsigned int spacing);
207 
209 
211  void extractScalarSeq (unsigned int initialPos,
212  unsigned int spacing,
213  unsigned int numPos,
214  unsigned int paramId,
215  ScalarSequence<double>& scalarSeq) const;
216 
217 #ifdef UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
218  void uniformlySampledMdf (const V& numEvaluationPointsVec,
219  ArrayOfOneDGrids <V,M>& mdfGrids,
220  ArrayOfOneDTables<V,M>& mdfValues) const;
221 #endif
222 
223 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
224  void uniformlySampledCdf (const V& numEvaluationPointsVec,
225  ArrayOfOneDGrids <V,M>& cdfGrids,
226  ArrayOfOneDTables<V,M>& cdfValues) const;
227  void bmm (unsigned int initialPos,
228  unsigned int batchLength,
229  V& bmmVec) const;
230  void fftForward (unsigned int initialPos,
231  unsigned int fftSize,
232  unsigned int paramId,
233  std::vector<std::complex<double> >& resultData) const;
234 //void fftInverse (unsigned int fftSize);
235 
236  void psd (unsigned int initialPos,
237  unsigned int numBlocks,
238  double hopSizeRatio,
239  unsigned int paramId,
240  std::vector<double>& psdResult) const;
241  void psdAtZero (unsigned int initialPos,
242  unsigned int numBlocks,
243  double hopSizeRatio,
244  V& psdVec) const;
245  void geweke (unsigned int initialPos,
246  double ratioNa,
247  double ratioNb,
248  V& gewVec) const;
249 #endif
250 
251 
252 private:
254 
257  void extractRawData (unsigned int initialPos,
258  unsigned int spacing,
259  unsigned int numPos,
260  unsigned int paramId,
261  std::vector<double>& rawData) const;
262 
265 
270 };
271 
272 } // End namespace QUESO
273 
274 #endif // UQ_ARRAY_OF_SEQUENCES_H
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 ...
Class to accommodate arrays of one-dimensional grid.
void interQuantileRange(unsigned int initialPos, V &iqrs) const
Returns the interquartile range of the values in the sequence.
Class for matrix operations using GSL library.
Definition: GslMatrix.h:47
void autoCorrViaDef(unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const
Calculates autocorrelation via definition.
void filter(unsigned int initialPos, unsigned int spacing)
Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spaci...
ArrayOfSequences(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
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.
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...
void autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
Calculates the autocovariance.
void unifiedWriteContents(std::ofstream &ofsvar) const
Writes info of the unified sequence to a file.
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...
Class for handling array samples (arrays of scalar sequences).
void writeContents(std::ofstream &ofsvar) const
Write contents of the chain to a file.
void getPositionValues(unsigned int posId, V &vec) const
Gets the values of the sequence at position posId and stores them at vec.
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...
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace&lt;V,M&gt;&amp; m_vectorSpace.
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...
Class for vector operations using GSL library.
Definition: GslVector.h:48
void erasePositions(unsigned int initialPos, unsigned int numPos)
Erases numPos elements of the sequence starting at position initialPos.
void autoCorrViaFft(unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const
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 init...
void gaussianKDE(const V &evaluationParamVec, V &densityVec) const
Gaussian kernel for the KDE estimate of the sequence.
A class for partitioning vectors and matrices.
Definition: DistArray.h:56
void extractRawData(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
Extracts the raw data.
Class to accommodate arrays of one-dimensional tables.
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
void resizeSequence(unsigned int newSubSequenceSize)
Resizes the sequence.
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
void unifiedReadContents(const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)
Reads the unified sequence from a file.
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...
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...
void setPositionValues(unsigned int posId, const V &vec)
Set the values of vec at position posId of the sequence.
A class representing a vector space.
Definition: VectorSet.h:49
void select(const std::vector< unsigned int > &idsOfUniquePositions)
Select positions in the sequence of vectors.
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 ...
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...
void resetValues(unsigned int initialPos, unsigned int numPos)
Resets a total of numPos values of the sequence starting at position initialPos.
Base class for handling vector and array samples (sequence of vectors or arrays). ...
~ArrayOfSequences()
Destructor.

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5