26 #include <queso/VectorSequence.h>
27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
33 template <
class V,
class M>
36 unsigned int subSequenceSize,
37 const std::string& name)
39 m_env (vectorSpace.env()),
40 m_vectorSpace (vectorSpace),
42 m_fftObj (new
Fft<double>(m_env)),
44 m_unifiedMinPlain (NULL),
46 m_unifiedMaxPlain (NULL),
47 m_subMeanPlain (NULL),
48 m_unifiedMeanPlain (NULL),
49 m_subMedianPlain (NULL),
50 m_unifiedMedianPlain (NULL),
51 m_subSampleVariancePlain (NULL),
52 m_unifiedSampleVariancePlain(NULL),
54 m_unifiedBoxPlain (NULL)
56 if (subSequenceSize) {};
59 template <
class V,
class M>
63 this->deleteStoredVectors();
64 if (m_fftObj != NULL)
delete m_fftObj;
68 template <
class V,
class M>
72 unsigned int unifiedNumSamples = 0;
74 bool useOnlyInter0Comm = (m_vectorSpace.numOfProcsForStorage() == 1);
76 if (useOnlyInter0Comm) {
77 if (m_env.inter0Rank() >= 0) {
78 unsigned int subNumSamples = this->subSequenceSize();
80 "BaseVectorSequence<V,M>::unifiedSequenceSize()",
81 "failed MPI.Allreduce() for unifiedSequenceSize()");
85 unifiedNumSamples = this->subSequenceSize();
92 return unifiedNumSamples;
95 template <
class V,
class M>
99 return m_vectorSpace.dimLocal();
102 template <
class V,
class M>
106 return m_vectorSpace.dimGlobal();
109 template <
class V,
class M>
113 return m_vectorSpace;
116 template <
class V,
class M>
123 template <
class V,
class M>
131 template <
class V,
class M>
135 unsigned int numPos = this->subSequenceSize();
137 this->resetValues(0,numPos);
138 this->resizeSequence(0);
144 template <
class V,
class M>
148 if (m_subMinPlain == NULL) {
149 m_subMinPlain = m_vectorSpace.newVector();
150 if (m_subMaxPlain == NULL) m_subMaxPlain = m_vectorSpace.newVector();
151 subMinMaxExtra(0,this->subSequenceSize(),*m_subMinPlain,*m_subMaxPlain);
154 return *m_subMinPlain;
157 template <
class V,
class M>
161 if (m_unifiedMinPlain == NULL) {
162 m_unifiedMinPlain = m_vectorSpace.newVector();
163 if (m_unifiedMaxPlain == NULL) m_unifiedMaxPlain = m_vectorSpace.newVector();
164 unifiedMinMaxExtra(0,this->subSequenceSize(),*m_unifiedMinPlain,*m_unifiedMaxPlain);
167 return *m_unifiedMinPlain;
170 template <
class V,
class M>
174 if (m_subMaxPlain == NULL) {
175 if (m_subMinPlain == NULL) m_subMinPlain = m_vectorSpace.newVector();
176 m_subMaxPlain = m_vectorSpace.newVector();
177 subMinMaxExtra(0,this->subSequenceSize(),*m_subMinPlain,*m_subMaxPlain);
180 return *m_subMaxPlain;
183 template <
class V,
class M>
187 if (m_unifiedMaxPlain == NULL) {
188 if (m_unifiedMinPlain == NULL) m_unifiedMinPlain = m_vectorSpace.newVector();
189 m_unifiedMaxPlain = m_vectorSpace.newVector();
190 unifiedMinMaxExtra(0,this->subSequenceSize(),*m_unifiedMinPlain,*m_unifiedMaxPlain);
193 return *m_unifiedMaxPlain;
196 template <
class V,
class M>
200 if (m_subMeanPlain == NULL) {
201 m_subMeanPlain = m_vectorSpace.newVector();
202 subMeanExtra(0,subSequenceSize(),*m_subMeanPlain);
205 return *m_subMeanPlain;
208 template <
class V,
class M>
212 if (m_unifiedMeanPlain == NULL) {
213 m_unifiedMeanPlain = m_vectorSpace.newVector();
214 unifiedMeanExtra(0,subSequenceSize(),*m_unifiedMeanPlain);
217 return *m_unifiedMeanPlain;
220 template <
class V,
class M>
224 if (m_subMedianPlain == NULL) {
225 m_subMedianPlain = m_vectorSpace.newVector();
226 subMedianExtra(0, subSequenceSize(), *m_subMedianPlain);
229 return *m_subMedianPlain;
232 template <
class V,
class M>
236 if (m_unifiedMedianPlain == NULL) {
237 m_unifiedMedianPlain = m_vectorSpace.newVector();
238 unifiedMedianExtra(0, subSequenceSize(), *m_unifiedMedianPlain);
241 return *m_unifiedMedianPlain;
244 template <
class V,
class M>
248 if (m_subSampleVariancePlain == NULL) {
249 m_subSampleVariancePlain = m_vectorSpace.newVector();
250 subSampleVarianceExtra(0,subSequenceSize(),subMeanPlain(),*m_subSampleVariancePlain);
253 return *m_subSampleVariancePlain;
256 template <
class V,
class M>
260 if (m_unifiedSampleVariancePlain == NULL) {
261 m_unifiedSampleVariancePlain = m_vectorSpace.newVector();
262 unifiedSampleVarianceExtra(0,subSequenceSize(),unifiedMeanPlain(),*m_unifiedSampleVariancePlain);
265 return *m_unifiedSampleVariancePlain;
268 template <
class V,
class M>
272 if (m_subBoxPlain == NULL) {
276 this->subMaxPlain());
279 return *m_subBoxPlain;
282 template <
class V,
class M>
286 if (m_unifiedBoxPlain == NULL) {
289 this->unifiedMinPlain(),
290 this->unifiedMaxPlain());
293 return *m_unifiedBoxPlain;
296 template <
class V,
class M>
301 delete m_subMinPlain;
302 m_subMinPlain = NULL;
304 if (m_unifiedMinPlain) {
305 delete m_unifiedMinPlain;
306 m_unifiedMinPlain = NULL;
309 delete m_subMaxPlain;
310 m_subMaxPlain = NULL;
312 if (m_unifiedMaxPlain) {
313 delete m_unifiedMaxPlain;
314 m_unifiedMaxPlain = NULL;
316 if (m_subMeanPlain) {
317 delete m_subMeanPlain;
318 m_subMeanPlain = NULL;
320 if (m_unifiedMeanPlain) {
321 delete m_unifiedMeanPlain;
322 m_unifiedMeanPlain = NULL;
324 if (m_subMedianPlain) {
325 delete m_subMedianPlain;
326 m_subMedianPlain = NULL;
328 if (m_unifiedMedianPlain) {
329 delete m_unifiedMedianPlain;
330 m_unifiedMedianPlain = NULL;
332 if (m_subSampleVariancePlain) {
333 delete m_subSampleVariancePlain;
334 m_subSampleVariancePlain = NULL;
336 if (m_unifiedSampleVariancePlain) {
337 delete m_unifiedSampleVariancePlain;
338 m_unifiedSampleVariancePlain = NULL;
341 delete m_subBoxPlain;
342 m_subBoxPlain = NULL;
344 if (m_unifiedBoxPlain) {
345 delete m_unifiedBoxPlain;
346 m_unifiedBoxPlain = NULL;
352 template <
class V,
class M>
356 unsigned int initialPos,
363 this->deleteStoredVectors();
364 unsigned int currentSize = this->subSequenceSize();
365 this->resizeSequence(currentSize+numPos);
367 for (
unsigned int i = 0; i < numPos; ++i) {
369 this->setPositionValues(currentSize+i,tmpVec);
375 template <
class V,
class M>
381 if (m_env.subDisplayFile()) {
382 *m_env.subDisplayFile() <<
"Entering BaseVectorSequence<V,M>::subPositionsOfMaximum()"
383 <<
": subCorrespondingScalarValues,subSequenceSize() = " << subCorrespondingScalarValues.
subSequenceSize()
384 <<
", this->subSequenceSize = " << this->subSequenceSize()
390 double subMaxValue = subCorrespondingScalarValues.
subMaxPlain();
393 unsigned int subNumPos = 0;
394 for (
unsigned int i = 0; i < iMax; ++i) {
395 if (subCorrespondingScalarValues[i] == subMaxValue) {
400 V tmpVec(this->vectorSpace().zeroVector());
403 for (
unsigned int i = 0; i < iMax; ++i) {
404 if (subCorrespondingScalarValues[i] == subMaxValue) {
405 this->getPositionValues (i,tmpVec);
411 if (m_env.subDisplayFile()) {
412 *m_env.subDisplayFile() <<
"Leaving BaseVectorSequence<V,M>::subPositionsOfMaximum()"
419 template <
class V,
class M>
425 if (m_env.subDisplayFile()) {
426 *m_env.subDisplayFile() <<
"Entering BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()"
427 <<
": subCorrespondingScalarValues,subSequenceSize() = " << subCorrespondingScalarValues.
subSequenceSize()
428 <<
", this->subSequenceSize = " << this->subSequenceSize()
435 double subMaxValue = subCorrespondingScalarValues.
subMaxPlain();
440 double unifiedMaxValue;
441 std::vector<double> sendbufPos(1,0.);
442 for (
unsigned int i = 0; i < sendbufPos.size(); ++i) {
443 sendbufPos[i] = subMaxValue;
446 "BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()",
447 "failed MPI.Allreduce() for max");
453 for (
unsigned int i = 0; i < iMax; ++i) {
454 if (subCorrespondingScalarValues[i] == unifiedMaxValue) {
461 V tmpVec(this->vectorSpace().zeroVector());
464 for (
unsigned int i = 0; i < iMax; ++i) {
466 if (subCorrespondingScalarValues[i] == unifiedMaxValue) {
467 this->getPositionValues (i,tmpVec);
474 std::vector<int> auxBuf(1,0);
475 int unifiedNumPos = 0;
476 auxBuf[0] = subNumPos;
478 "BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()",
479 "failed MPI.Allreduce() for sum");
488 unsigned int Np = (
unsigned int) m_env.inter0Comm().NumProc();
490 std::vector<int> recvcntsPos(Np,0);
492 "BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()",
493 "failed MPI.Gatherv()");
494 if (m_env.inter0Rank() == 0) {
499 std::vector<int> displsPos(Np,0);
500 for (
unsigned int nodeId = 1; nodeId < Np; ++nodeId) {
501 displsPos[nodeId] = displsPos[nodeId-1] + recvcntsPos[nodeId-1];
503 if (m_env.inter0Rank() == 0) {
504 queso_require_equal_to_msg(unifiedNumPos, (displsPos[Np - 1] + recvcntsPos[Np - 1]),
"failed MPI.Gather() result at proc 0 (unifiedNumPos)");
515 unsigned int dimSize = m_vectorSpace.dimLocal();
516 int subNumDbs = subNumPos * dimSize;
517 std::vector<int> recvcntsDbs(Np,0);
519 "BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()",
520 "failed MPI.Gatherv()");
521 if (m_env.inter0Rank() == 0) {
527 std::vector<int> displsDbs(Np,0);
528 for (
unsigned int nodeId = 1; nodeId < Np; ++nodeId) {
529 displsDbs[nodeId] = displsDbs[nodeId-1] + recvcntsDbs[nodeId-1];
531 if (m_env.inter0Rank() == 0) {
532 queso_require_equal_to_msg(((
int) (unifiedNumPos*dimSize)), (displsDbs[Np - 1] + recvcntsDbs[Np - 1]),
"failed MPI.Gather() result at proc 0 (unifiedNumPos*dimSize)");
540 std::vector<double> sendbufDbs(subNumDbs,0.);
541 for (
unsigned int i = 0; i < (
unsigned int) subNumPos; ++i) {
543 for (
unsigned int j = 0; j < dimSize; ++j) {
544 sendbufDbs[i*dimSize + j] = tmpVec[j];
548 std::vector<double> recvbufDbs(unifiedNumPos * dimSize);
551 m_env.inter0Comm().Gatherv((
void *) &sendbufDbs[0], (
int) subNumDbs,
RawValue_MPI_DOUBLE, (
void *) &recvbufDbs[0], (
int *) &recvcntsDbs[0], (
int *) &displsDbs[0],
RawValue_MPI_DOUBLE, 0,
552 "BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()",
553 "failed MPI.Gatherv()");
560 if (m_env.inter0Rank() == (int) 0) {
561 for (
unsigned int i = 0; i < (
unsigned int) unifiedNumPos; ++i) {
562 for (
unsigned int j = 0; j < dimSize; ++j) {
563 tmpVec[j] = recvbufDbs[i*dimSize + j];
574 if (m_env.subDisplayFile()) {
575 *m_env.subDisplayFile() <<
"Leaving BaseVectorSequence<V,M>::unifiedPositionsOfMaximum()"
579 return unifiedMaxValue;
582 template <
class V,
class M>
586 V gaussianVector(m_vectorSpace.zeroVector());
587 for (
unsigned int j = 0; j < this->subSequenceSize(); ++j) {
588 gaussianVector.cwSetGaussian(meanVec,stdDevVec);
589 this->setPositionValues(j,gaussianVector);
592 this->deleteStoredVectors();
597 template <
class V,
class M>
601 V uniformVector(m_vectorSpace.zeroVector());
602 for (
unsigned int j = 0; j < this->subSequenceSize(); ++j) {
603 uniformVector.cwSetUniform(aVec,bVec);
604 this->setPositionValues(j,uniformVector);
607 this->deleteStoredVectors();
612 template<
class V,
class M>
615 std::ofstream* passedOfs,
616 unsigned int& initialPos,
617 unsigned int& spacing)
619 if (m_env.subDisplayFile()) {
620 *m_env.subDisplayFile() <<
"\n"
621 <<
"\n-----------------------------------------------------"
622 <<
"\n Computing filter parameters for chain '" << m_name <<
"' ..."
623 <<
"\n-----------------------------------------------------"
628 bool okSituation = ((passedOfs == NULL ) ||
629 ((passedOfs != NULL) && (m_env.subRank() >= 0)));
630 queso_require_msg(!(!okSituation),
"unexpected combination of file pointer and subRank");
635 if (m_env.subDisplayFile()) {
636 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
637 <<
"\n Finished computing filter parameters for chain '" << m_name <<
"'"
638 <<
": initialPos = " << initialPos
639 <<
", spacing = " << spacing
640 <<
"\n-----------------------------------------------------"
649 template <
class V,
class M>
658 this->deleteStoredVectors();
668 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
669 template<
class V,
class M>
672 const SequenceStatisticalOptions& statisticalOptions,
673 std::ofstream* passedOfs)
676 computeStatistics(statisticalOptions.m_ov, passedOfs);
679 template<
class V,
class M>
681 BaseVectorSequence<V,M>::computeStatistics(
682 const SsOptionsValues& statisticalOptions,
683 std::ofstream* passedOfs)
685 if (m_env.subDisplayFile()) {
686 *m_env.subDisplayFile() <<
"\n"
687 <<
"\n-----------------------------------------------------"
688 <<
"\n Computing statistics for chain '" << m_name <<
"' ..."
689 <<
"\n-----------------------------------------------------"
694 bool okSituation = ((passedOfs == NULL ) ||
695 ((passedOfs != NULL) && (m_env.subRank() >= 0)));
696 queso_require_msg(!(!okSituation),
"unexpected combination of file pointer and subRank");
699 struct timeval timevalTmp;
700 iRC = gettimeofday(&timevalTmp, NULL);
701 double tmpRunTime = 0.;
704 std::vector<unsigned int> initialPosForStatistics(statisticalOptions.initialDiscardedPortions().size(),0);
705 for (
unsigned int i = 0; i < initialPosForStatistics.size(); ++i) {
706 initialPosForStatistics[i] = (
unsigned int) (statisticalOptions.initialDiscardedPortions()[i] * (double) (this->subSequenceSize()-1));
707 if (m_env.subDisplayFile()) {
708 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeStatistics()"
709 <<
": statisticalOptions.initialDiscardedPortions()[" << i <<
"] = " << statisticalOptions.initialDiscardedPortions()[i]
710 <<
", initialPosForStatistics[" << i <<
"] = " << initialPosForStatistics[i]
714 if (m_env.subDisplayFile()) {
715 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeStatistics(): initial positions for statistics =";
716 for (
unsigned int i = 0; i < initialPosForStatistics.size(); ++i) {
717 *m_env.subDisplayFile() <<
" " << initialPosForStatistics[i];
719 *m_env.subDisplayFile() << std::endl;
725 this->computeMeanVars(statisticalOptions,
732 #ifdef UQ_CODE_HAS_MONITORS
733 if (statisticalOptions.meanMonitorPeriod() != 0) {
734 this->computeMeanEvolution(statisticalOptions,
742 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
743 if ((statisticalOptions.bmmRun() ) &&
744 (initialPosForStatistics.size() > 0) &&
745 (statisticalOptions.bmmLengths().size() > 0)) {
746 this->computeBMM(statisticalOptions,
747 initialPosForStatistics,
754 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
755 if ((statisticalOptions.fftCompute() ) &&
756 (initialPosForStatistics.size() > 0)) {
757 this->computeFFT(statisticalOptions,
758 initialPosForStatistics,
765 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
766 if ((statisticalOptions.psdCompute() ) &&
767 (initialPosForStatistics.size() > 0)) {
768 this->computePSD(statisticalOptions,
769 initialPosForStatistics,
776 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
777 if ((statisticalOptions.psdAtZeroCompute() ) &&
778 (initialPosForStatistics.size() > 0) &&
779 (statisticalOptions.psdAtZeroNumBlocks().size() > 0)) {
780 this->computePSDAtZero(statisticalOptions,
781 initialPosForStatistics,
788 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
789 if ((statisticalOptions.gewekeCompute()) &&
790 (initialPosForStatistics.size() > 0)) {
791 this->computeGeweke(statisticalOptions,
792 initialPosForStatistics,
799 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
800 if ((statisticalOptions.meanStaccCompute()) &&
801 (initialPosForStatistics.size() > 0 )) {
802 this->computeMeanStacc(statisticalOptions,
803 initialPosForStatistics,
808 std::vector<unsigned int> lagsForCorrs(statisticalOptions.autoCorrNumLags(),1);
809 for (
unsigned int i = 1; i < lagsForCorrs.size(); ++i) {
810 lagsForCorrs[i] = statisticalOptions.autoCorrSecondLag() + (i-1)*statisticalOptions.autoCorrLagSpacing();
816 if ((statisticalOptions.autoCorrComputeViaDef()) &&
817 (initialPosForStatistics.size() > 0 ) &&
818 (lagsForCorrs.size() > 0 )) {
819 this->computeAutoCorrViaDef(statisticalOptions,
820 initialPosForStatistics,
828 if ((statisticalOptions.autoCorrComputeViaFft()) &&
829 (initialPosForStatistics.size() > 0 ) &&
830 (lagsForCorrs.size() > 0 )) {
831 this->computeAutoCorrViaFFT(statisticalOptions,
832 initialPosForStatistics,
840 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
841 if ((statisticalOptions.histCompute ()) ||
842 (statisticalOptions.cdfStaccCompute()) ||
843 (statisticalOptions.kdeCompute ())) {
845 if (statisticalOptions.kdeCompute())
847 this->computeHistCdfstaccKde(statisticalOptions,
854 if ((statisticalOptions.covMatrixCompute ()) ||
855 (statisticalOptions.corrMatrixCompute())) {
856 this->computeCovCorrMatrices(statisticalOptions,
861 if (m_env.subDisplayFile()) {
862 *m_env.subDisplayFile() <<
"All statistics of chain '" << m_name <<
"'"
863 <<
" took " << tmpRunTime
868 if (m_env.subDisplayFile()) {
869 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
870 <<
"\n Finished computing statistics for chain '" << m_name <<
"'"
871 <<
"\n-----------------------------------------------------"
879 template<
class V,
class M>
881 BaseVectorSequence<V,M>::computeMeanVars(
882 const SequenceStatisticalOptions& statisticalOptions,
883 std::ofstream* passedOfs,
890 computeMeanVars(statisticalOptions.m_ov, passedOfs, subMeanPtr, subMedianPtr,
891 subSampleVarPtr, subPopulVarPtr);
894 template<
class V,
class M>
896 BaseVectorSequence<V,M>::computeMeanVars(
897 const SsOptionsValues& statisticalOptions,
898 std::ofstream* passedOfs,
905 struct timeval timevalTmp;
906 iRC = gettimeofday(&timevalTmp, NULL);
907 double tmpRunTime = 0.;
909 if (m_env.subDisplayFile()) {
910 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
911 <<
"\nComputing mean, sample variance and population variance"
915 V subChainMean(m_vectorSpace.zeroVector());
916 this->subMeanExtra(0,
917 this->subSequenceSize(),
920 V subChainMedian(m_vectorSpace.zeroVector());
921 this->subMedianExtra(0,
922 this->subSequenceSize(),
925 V subChainSampleVariance(m_vectorSpace.zeroVector());
926 this->subSampleVarianceExtra(0,
927 this->subSequenceSize(),
929 subChainSampleVariance);
931 if ((m_env.displayVerbosity() >= 5) && (m_env.subDisplayFile())) {
932 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeMeanVars()"
933 <<
": subChainMean.sizeLocal() = " << subChainMean.sizeLocal()
934 <<
", subChainMean = " << subChainMean
935 <<
", subChainMedian = " << subChainMedian
936 <<
", subChainSampleVariance.sizeLocal() = " << subChainSampleVariance.sizeLocal()
937 <<
", subChainSampleVariance = " << subChainSampleVariance
941 V estimatedVarianceOfSampleMean(subChainSampleVariance);
942 estimatedVarianceOfSampleMean /= (double) this->subSequenceSize();
943 bool savedVectorPrintState = estimatedVarianceOfSampleMean.getPrintHorizontally();
944 estimatedVarianceOfSampleMean.setPrintHorizontally(
false);
945 if (m_env.subDisplayFile()) {
946 *m_env.subDisplayFile() <<
"\nEstimated variance of sample mean for the whole chain '" << m_name <<
"'"
947 <<
", under independence assumption:"
949 << estimatedVarianceOfSampleMean
952 estimatedVarianceOfSampleMean.setPrintHorizontally(savedVectorPrintState);
954 V estimatedStdOfSampleMean(estimatedVarianceOfSampleMean);
955 estimatedStdOfSampleMean.cwSqrt();
956 savedVectorPrintState = estimatedStdOfSampleMean.getPrintHorizontally();
957 estimatedStdOfSampleMean.setPrintHorizontally(
false);
958 if (m_env.subDisplayFile()) {
959 *m_env.subDisplayFile() <<
"\nEstimated standard deviation of sample mean for the whole chain '" << m_name <<
"'"
960 <<
", under independence assumption:"
962 << estimatedStdOfSampleMean
965 estimatedStdOfSampleMean.setPrintHorizontally(savedVectorPrintState);
967 V subChainPopulationVariance(m_vectorSpace.zeroVector());
968 this->subPopulationVariance(0,
969 this->subSequenceSize(),
971 subChainPopulationVariance);
974 if (m_env.subDisplayFile()) {
975 *m_env.subDisplayFile() <<
"Sub Mean, median, and variances took " << tmpRunTime
980 if (m_env.subDisplayFile()) {
981 *m_env.subDisplayFile() <<
"\nSub mean, median, sample std, population std"
984 sprintf(line,
"%s%4s%s%6s%s%9s%s%9s%s",
994 *m_env.subDisplayFile() << line;
996 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
997 sprintf(line,
"\n%8.8s%2s%11.4e%2s%11.4e%2s%11.4e%2s%11.4e",
998 m_vectorSpace.localComponentName(i).c_str(),
1004 std::sqrt(subChainSampleVariance[i]),
1006 std::sqrt(subChainPopulationVariance[i]));
1007 *m_env.subDisplayFile() << line;
1009 *m_env.subDisplayFile() << std::endl;
1012 if (subMeanPtr ) *subMeanPtr = subChainMean;
1013 if (subMedianPtr ) *subMedianPtr = subChainMedian;
1014 if (subSampleVarPtr) *subSampleVarPtr = subChainSampleVariance;
1015 if (subPopulVarPtr ) *subPopulVarPtr = subChainPopulationVariance;
1017 if (m_env.numSubEnvironments() > 1) {
1019 if (m_vectorSpace.numOfProcsForStorage() == 1) {
1020 V unifiedChainMean(m_vectorSpace.zeroVector());
1021 this->unifiedMeanExtra(0,
1022 this->subSequenceSize(),
1025 V unifiedChainMedian(m_vectorSpace.zeroVector());
1026 this->unifiedMedianExtra(0,
1027 this->subSequenceSize(),
1028 unifiedChainMedian);
1030 V unifiedChainSampleVariance(m_vectorSpace.zeroVector());
1031 this->unifiedSampleVarianceExtra(0,
1032 this->subSequenceSize(),
1034 unifiedChainSampleVariance);
1036 V unifiedChainPopulationVariance(m_vectorSpace.zeroVector());
1037 this->unifiedPopulationVariance(0,
1038 this->subSequenceSize(),
1040 unifiedChainPopulationVariance);
1042 if (m_env.inter0Rank() == 0) {
1043 if (m_env.subDisplayFile()) {
1044 *m_env.subDisplayFile() <<
"\nUnif mean, median, sample std, population std"
1047 sprintf(line,
"%s%4s%s%6s%s%9s%s%9s%s",
1057 *m_env.subDisplayFile() << line;
1059 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1060 sprintf(line,
"\n%8.8s%2s%11.4e%2s%11.4e%2s%11.4e%2s%11.4e",
1061 m_vectorSpace.localComponentName(i).c_str(),
1063 unifiedChainMean[i],
1065 unifiedChainMedian[i],
1067 std::sqrt(unifiedChainSampleVariance[i]),
1069 std::sqrt(unifiedChainPopulationVariance[i]));
1070 *m_env.subDisplayFile() << line;
1072 *m_env.subDisplayFile() << std::endl;
1077 queso_error_msg(
"unified min-max writing, parallel vectors not supported yet");
1081 if (m_env.subDisplayFile()) {
1082 *m_env.subDisplayFile() <<
"\nEnded computing mean, sample variance and population variance"
1083 <<
"\n-----------------------------------------------------"
1090 template<
class V,
class M>
1092 BaseVectorSequence<V,M>::computeAutoCorrViaDef(
1093 const SequenceStatisticalOptions& statisticalOptions,
1094 const std::vector<unsigned int>& initialPosForStatistics,
1095 const std::vector<unsigned int>& lagsForCorrs,
1096 std::ofstream* passedOfs)
1099 computeAutoCorrViaDef(statisticalOptions.m_ov, initialPosForStatistics,
1100 lagsForCorrs, passedOfs);
1103 template<
class V,
class M>
1105 BaseVectorSequence<V,M>::computeAutoCorrViaDef(
1106 const SsOptionsValues& statisticalOptions,
1107 const std::vector<unsigned int>& initialPosForStatistics,
1108 const std::vector<unsigned int>& lagsForCorrs,
1109 std::ofstream* passedOfs)
1112 struct timeval timevalTmp;
1113 iRC = gettimeofday(&timevalTmp, NULL);
1114 double tmpRunTime = 0.;
1116 if (m_env.subDisplayFile()) {
1117 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1118 <<
"\nComputing autocorrelation coefficients (via def)"
1122 if (statisticalOptions.autoCorrDisplay() && (m_env.subDisplayFile())) {
1123 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeAutoCorrViaDef(): lags for autocorrelation (via def) = ";
1124 for (
unsigned int i = 0; i < lagsForCorrs.size(); ++i) {
1125 *m_env.subDisplayFile() <<
" " << lagsForCorrs[i];
1127 *m_env.subDisplayFile() << std::endl;
1130 TwoDArray<V> _2dArrayOfAutoCorrs(initialPosForStatistics.size(),lagsForCorrs.size());
1131 for (
unsigned int i = 0; i < _2dArrayOfAutoCorrs.numRows(); ++i) {
1132 for (
unsigned int j = 0; j < _2dArrayOfAutoCorrs.numCols(); ++j) {
1133 _2dArrayOfAutoCorrs.setLocation(i,j,
new V(m_vectorSpace.zeroVector()) );
1137 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1138 unsigned int initialPos = initialPosForStatistics[initialPosId];
1139 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1140 unsigned int lag = lagsForCorrs[lagId];
1141 this->autoCorrViaDef(initialPos,
1142 this->subSequenceSize()-initialPos,
1144 _2dArrayOfAutoCorrs(initialPosId,lagId));
1152 if ((statisticalOptions.autoCorrDisplay()) && (m_env.subDisplayFile())) {
1153 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1154 *m_env.subDisplayFile() <<
"\nComputed autocorrelation coefficients (via def), for subchain beginning at position " << initialPosForStatistics[initialPosId]
1155 <<
" (each column corresponds to a different lag)"
1160 *m_env.subDisplayFile() << line;
1161 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1162 sprintf(line,
"%10s%3d",
1164 lagsForCorrs[lagId]);
1165 *m_env.subDisplayFile() << line;
1168 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1169 sprintf(line,
"\n%9.9s",
1170 m_vectorSpace.localComponentName(i).c_str() );
1171 *m_env.subDisplayFile() << line;
1172 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1173 sprintf(line,
"%2s%11.4e",
1175 _2dArrayOfAutoCorrs(initialPosId,lagId)[i]);
1176 *m_env.subDisplayFile() << line;
1179 *m_env.subDisplayFile() << std::endl;
1184 if (m_env.subDisplayFile()) {
1185 *m_env.subDisplayFile() <<
"Chain autocorrelation (via def) took " << tmpRunTime
1191 if (statisticalOptions.autoCorrWrite() && passedOfs) {
1192 std::ofstream& ofsvar = *passedOfs;
1193 ofsvar << m_name <<
"_corrViaDefLags_sub" << m_env.subIdString() <<
" = zeros(" << 1
1194 <<
"," << lagsForCorrs.size()
1197 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1198 ofsvar << m_name <<
"_corrViaDefLags_sub" << m_env.subIdString() <<
"(" << 1
1200 <<
") = " << lagsForCorrs[lagId]
1205 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1206 ofsvar << m_name <<
"_corrViaDefInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << this->vectorSizeLocal()
1207 <<
"," << lagsForCorrs.size()
1210 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1211 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1212 ofsvar << m_name <<
"_corrViaDefInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << i+1
1214 <<
") = " << _2dArrayOfAutoCorrs(initialPosId,lagId)[i]
1225 template<
class V,
class M>
1227 BaseVectorSequence<V,M>::computeAutoCorrViaFFT(
1228 const SequenceStatisticalOptions& statisticalOptions,
1229 const std::vector<unsigned int>& initialPosForStatistics,
1230 const std::vector<unsigned int>& lagsForCorrs,
1231 std::ofstream* passedOfs)
1234 computeAutoCorrViaFFT(statisticalOptions.m_ov, initialPosForStatistics,
1235 lagsForCorrs, passedOfs);
1238 template<
class V,
class M>
1240 BaseVectorSequence<V,M>::computeAutoCorrViaFFT(
1241 const SsOptionsValues& statisticalOptions,
1242 const std::vector<unsigned int>& initialPosForStatistics,
1243 const std::vector<unsigned int>& lagsForCorrs,
1244 std::ofstream* passedOfs)
1247 struct timeval timevalTmp;
1248 iRC = gettimeofday(&timevalTmp, NULL);
1249 double tmpRunTime = 0.;
1251 if (m_env.subDisplayFile()) {
1252 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1253 <<
"\nComputing autocorrelation coefficients (via fft)"
1257 if (statisticalOptions.autoCorrDisplay() && (m_env.subDisplayFile())) {
1258 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeAutoCorrViaFFT(): lags for autocorrelation (via fft) = ";
1259 for (
unsigned int i = 0; i < lagsForCorrs.size(); ++i) {
1260 *m_env.subDisplayFile() <<
" " << lagsForCorrs[i];
1262 *m_env.subDisplayFile() << std::endl;
1265 TwoDArray<V> _2dArrayOfAutoCorrs(initialPosForStatistics.size(),lagsForCorrs.size());
1266 for (
unsigned int i = 0; i < _2dArrayOfAutoCorrs.numRows(); ++i) {
1267 for (
unsigned int j = 0; j < _2dArrayOfAutoCorrs.numCols(); ++j) {
1268 _2dArrayOfAutoCorrs.setLocation(i,j,
new V(m_vectorSpace.zeroVector()) );
1271 std::vector<V*> corrVecs(lagsForCorrs.size(),NULL);
1272 std::vector<V*> corrSumVecs(initialPosForStatistics.size(),NULL);
1273 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1274 corrSumVecs[initialPosId] =
new V(m_vectorSpace.zeroVector()) ;
1275 unsigned int initialPos = initialPosForStatistics[initialPosId];
1276 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1277 corrVecs[lagId] =
new V(m_vectorSpace.zeroVector()) ;
1279 if (m_env.subDisplayFile()) {
1280 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeAutoCorrViaFFT()"
1281 <<
": about to call chain.autoCorrViaFft()"
1282 <<
" with initialPos = " << initialPos
1283 <<
", numPos = " << this->subSequenceSize()-initialPos
1284 <<
", lagsForCorrs.size() = " << lagsForCorrs.size()
1285 <<
", corrVecs.size() = " << corrVecs.size()
1288 this->autoCorrViaFft(initialPos,
1289 this->subSequenceSize()-initialPos,
1292 this->autoCorrViaFft(initialPos,
1293 this->subSequenceSize()-initialPos,
1294 (
unsigned int) (1.0 * (
double) (this->subSequenceSize()-initialPos)),
1295 *corrSumVecs[initialPosId]);
1296 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1297 _2dArrayOfAutoCorrs(initialPosId,lagId) = *(corrVecs[lagId]);
1300 for (
unsigned int j = 0; j < corrVecs.size(); ++j) {
1301 if (corrVecs[j] != NULL)
delete corrVecs[j];
1304 if (statisticalOptions.autoCorrDisplay()) {
1305 V subChainMean (m_vectorSpace.zeroVector());
1306 V subChainSampleVariance (m_vectorSpace.zeroVector());
1307 V estimatedVarianceOfSampleMean(m_vectorSpace.zeroVector());
1308 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1309 unsigned int initialPos = initialPosForStatistics[initialPosId];
1311 this->subMeanExtra(initialPos,
1312 this->subSequenceSize()-initialPos,
1315 this->subSampleVarianceExtra(initialPos,
1316 this->subSequenceSize()-initialPos,
1318 subChainSampleVariance);
1320 if (m_env.subDisplayFile()) {
1321 *m_env.subDisplayFile() <<
"\nEstimated variance of sample mean, through autocorrelation (via fft), for subchain beginning at position " << initialPosForStatistics[initialPosId]
1324 estimatedVarianceOfSampleMean.cwSet(-1.);
1325 estimatedVarianceOfSampleMean += 2.* (*corrSumVecs[initialPosId]);
1326 estimatedVarianceOfSampleMean *= subChainSampleVariance;
1327 estimatedVarianceOfSampleMean /= (double) (this->subSequenceSize() - initialPos);
1328 bool savedVectorPrintState = estimatedVarianceOfSampleMean.getPrintHorizontally();
1329 estimatedVarianceOfSampleMean.setPrintHorizontally(
false);
1330 if (m_env.subDisplayFile()) {
1331 *m_env.subDisplayFile() << estimatedVarianceOfSampleMean
1334 estimatedVarianceOfSampleMean.setPrintHorizontally(savedVectorPrintState);
1336 if (m_env.subDisplayFile()) {
1337 *m_env.subDisplayFile() <<
"\nComputed autocorrelation coefficients (via fft), for subchain beginning at position " << initialPosForStatistics[initialPosId]
1338 <<
" (each column corresponds to a different lag)"
1344 *m_env.subDisplayFile() << line;
1345 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1346 sprintf(line,
"%10s%3d",
1348 lagsForCorrs[lagId]);
1349 *m_env.subDisplayFile() << line;
1352 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1353 sprintf(line,
"\n%9.9s",
1354 m_vectorSpace.localComponentName(i).c_str() );
1355 *m_env.subDisplayFile() << line;
1356 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1357 sprintf(line,
"%2s%11.4e",
1359 _2dArrayOfAutoCorrs(initialPosId,lagId)[i]);
1360 *m_env.subDisplayFile() << line;
1363 *m_env.subDisplayFile() << std::endl;
1369 if (m_env.subDisplayFile()) {
1370 *m_env.subDisplayFile() <<
"Chain autocorrelation (via fft) took " << tmpRunTime
1376 if (statisticalOptions.autoCorrWrite() && passedOfs) {
1377 std::ofstream& ofsvar = *passedOfs;
1378 ofsvar << m_name <<
"_corrViaFftLags_sub" << m_env.subIdString() <<
" = zeros(" << 1
1379 <<
"," << lagsForCorrs.size()
1382 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1383 ofsvar << m_name <<
"_corrViaFftLags_sub" << m_env.subIdString() <<
"(" << 1
1385 <<
") = " << lagsForCorrs[lagId]
1390 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
1391 ofsvar << m_name <<
"_corrViaFftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << this->vectorSizeLocal()
1392 <<
"," << lagsForCorrs.size()
1395 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1396 for (
unsigned int lagId = 0; lagId < lagsForCorrs.size(); lagId++) {
1397 ofsvar << m_name <<
"_corrViaFftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << i+1
1399 <<
") = " << _2dArrayOfAutoCorrs(initialPosId,lagId)[i]
1410 template<
class V,
class M>
1412 BaseVectorSequence<V,M>::computeHistCdfstaccKde(
1413 const SequenceStatisticalOptions& statisticalOptions,
1414 std::ofstream* passedOfs)
1417 computeHistCdfstaccKde(statisticalOptions.m_ov, passedOfs);
1420 template<
class V,
class M>
1422 BaseVectorSequence<V,M>::computeHistCdfstaccKde(
1423 const SsOptionsValues& statisticalOptions,
1424 std::ofstream* passedOfs)
1426 if (m_env.subDisplayFile()) {
1427 *m_env.subDisplayFile() <<
"\n"
1428 <<
"\n-----------------------------------------------------"
1429 <<
"\n Computing histogram and/or cdf stacc and/or Kde for chain '" << m_name <<
"' ..."
1430 <<
"\n-----------------------------------------------------"
1436 struct timeval timevalTmp;
1441 double tmpRunTime = 0.;
1442 iRC = gettimeofday(&timevalTmp, NULL);
1443 if (m_env.subDisplayFile()) {
1444 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1445 <<
"\nComputing min and max for histograms and Kde"
1449 V statsMinPositions(m_vectorSpace.zeroVector());
1450 V statsMaxPositions(m_vectorSpace.zeroVector());
1451 this->subMinMaxExtra(0,
1452 this->subSequenceSize(),
1456 if (m_env.subDisplayFile()) {
1457 *m_env.subDisplayFile() <<
"\nComputed min values and max values for chain '" << m_name <<
"'"
1463 *m_env.subDisplayFile() << line;
1465 sprintf(line,
"%9s%s%9s%s",
1470 *m_env.subDisplayFile() << line;
1472 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1473 sprintf(line,
"\n%8.8s",
1474 m_vectorSpace.localComponentName(i).c_str() );
1475 *m_env.subDisplayFile() << line;
1477 sprintf(line,
"%2s%11.4e%2s%11.4e",
1479 statsMinPositions[i],
1481 statsMaxPositions[i]);
1482 *m_env.subDisplayFile() << line;
1484 *m_env.subDisplayFile() << std::endl;
1487 V unifiedStatsMinPositions(statsMinPositions);
1488 V unifiedStatsMaxPositions(statsMaxPositions);
1489 if (m_env.numSubEnvironments() > 1) {
1491 this->unifiedMinMaxExtra(0,
1492 this->subSequenceSize(),
1493 unifiedStatsMinPositions,
1494 unifiedStatsMaxPositions);
1497 if (m_env.subDisplayFile()) {
1498 if (m_vectorSpace.numOfProcsForStorage() == 1) {
1499 if (m_env.inter0Rank() == 0) {
1500 *m_env.subDisplayFile() <<
"\nComputed unified min values and max values for chain '" << m_name <<
"'"
1506 *m_env.subDisplayFile() << line;
1508 sprintf(line,
"%9s%s%9s%s",
1513 *m_env.subDisplayFile() << line;
1515 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1516 sprintf(line,
"\n%8.8s",
1517 m_vectorSpace.localComponentName(i).c_str() );
1518 *m_env.subDisplayFile() << line;
1520 sprintf(line,
"%2s%11.4e%2s%11.4e",
1522 unifiedStatsMinPositions[i],
1524 unifiedStatsMaxPositions[i]);
1525 *m_env.subDisplayFile() << line;
1527 *m_env.subDisplayFile() << std::endl;
1531 queso_error_msg(
"unified min-max writing, parallel vectors not supported yet");
1538 if (m_env.subDisplayFile()) {
1539 *m_env.subDisplayFile() <<
"Chain min and max took " << tmpRunTime
1547 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
1548 if ((statisticalOptions.histCompute() ) &&
1549 (statisticalOptions.histNumInternalBins() > 0)) {
1551 iRC = gettimeofday(&timevalTmp, NULL);
1552 if (m_env.subDisplayFile()) {
1553 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1554 <<
"\nComputing histograms"
1558 std::string subCoreName_HistCenters((std::string)(
"_HistCenters_sub")+m_env.subIdString());
1559 std::string uniCoreName_HistCenters((std::string)(
"_unifHistCenters_sub")+m_env.subIdString());
1560 if (m_env.numSubEnvironments() == 1) subCoreName_HistCenters = uniCoreName_HistCenters;
1562 std::string subCoreName_HistQuantts((std::string)(
"_HistQuantts_sub")+m_env.subIdString());
1563 std::string uniCoreName_HistQuantts((std::string)(
"_unifHistQuantts_sub")+m_env.subIdString());
1564 if (m_env.numSubEnvironments() == 1) subCoreName_HistQuantts = uniCoreName_HistQuantts;
1566 for (
unsigned int i = 0; i < statsMaxPositions.sizeLocal(); ++i) {
1567 statsMaxPositions[i] *= (1. + 1.e-15);
1571 std::vector<V*> histCentersForAllBins(statisticalOptions.histNumInternalBins()+2,NULL);
1572 std::vector<V*> histQuanttsForAllBins(statisticalOptions.histNumInternalBins()+2,NULL);
1573 this->subHistogram(0,
1576 histCentersForAllBins,
1577 histQuanttsForAllBins);
1581 std::ofstream& ofsvar = *passedOfs;
1582 ofsvar << m_name << subCoreName_HistCenters <<
" = zeros(" << this->vectorSizeLocal()
1583 <<
"," << histCentersForAllBins.size()
1586 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1587 for (
unsigned int j = 0; j < histCentersForAllBins.size(); ++j) {
1588 ofsvar << m_name << subCoreName_HistCenters <<
"(" << i+1
1590 <<
") = " << (*(histCentersForAllBins[j]))[i]
1596 ofsvar << m_name << subCoreName_HistQuantts <<
" = zeros(" << this->vectorSizeLocal()
1597 <<
"," << histQuanttsForAllBins.size()
1600 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1601 for (
unsigned int j = 0; j < histQuanttsForAllBins.size(); ++j) {
1602 ofsvar << m_name << subCoreName_HistQuantts <<
"(" << i+1
1604 <<
") = " << (*(histQuanttsForAllBins[j]))[i]
1611 for (
unsigned int i = 0; i < histQuanttsForAllBins.size(); ++i) {
1612 if (histQuanttsForAllBins[i] != NULL)
delete histQuanttsForAllBins[i];
1614 for (
unsigned int i = 0; i < histCentersForAllBins.size(); ++i) {
1615 if (histCentersForAllBins[i] != NULL)
delete histCentersForAllBins[i];
1618 std::vector<V*> unifiedHistCentersForAllBins(statisticalOptions.histNumInternalBins()+2,NULL);
1619 std::vector<V*> unifiedHistQuanttsForAllBins(statisticalOptions.histNumInternalBins()+2,NULL);
1620 if (m_env.numSubEnvironments() > 1) {
1622 this->unifiedHistogram(0,
1623 unifiedStatsMinPositions,
1624 unifiedStatsMaxPositions,
1625 unifiedHistCentersForAllBins,
1626 unifiedHistQuanttsForAllBins);
1630 if (m_vectorSpace.numOfProcsForStorage() == 1) {
1631 if (m_env.inter0Rank() == 0) {
1632 std::ofstream& ofsvar = *passedOfs;
1633 ofsvar << m_name << uniCoreName_HistCenters <<
" = zeros(" << this->vectorSizeLocal()
1634 <<
"," << unifiedHistCentersForAllBins.size()
1637 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1638 for (
unsigned int j = 0; j < unifiedHistCentersForAllBins.size(); ++j) {
1639 ofsvar << m_name << uniCoreName_HistCenters <<
"(" << i+1
1641 <<
") = " << (*(unifiedHistCentersForAllBins[j]))[i]
1647 ofsvar << m_name << uniCoreName_HistQuantts <<
" = zeros(" << this->vectorSizeLocal()
1648 <<
"," << unifiedHistQuanttsForAllBins.size()
1651 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1652 for (
unsigned int j = 0; j < unifiedHistQuanttsForAllBins.size(); ++j) {
1653 ofsvar << m_name << uniCoreName_HistQuantts <<
"(" << i+1
1655 <<
") = " << (*(unifiedHistQuanttsForAllBins[j]))[i]
1663 queso_error_msg(
"unified histogram writing, parallel vectors not supported yet");
1667 for (
unsigned int i = 0; i < unifiedHistQuanttsForAllBins.size(); ++i) {
1668 if (unifiedHistQuanttsForAllBins[i] != NULL)
delete unifiedHistQuanttsForAllBins[i];
1670 for (
unsigned int i = 0; i < unifiedHistCentersForAllBins.size(); ++i) {
1671 if (unifiedHistCentersForAllBins[i] != NULL)
delete unifiedHistCentersForAllBins[i];
1677 if (m_env.subDisplayFile()) {
1678 *m_env.subDisplayFile() <<
"Chain histograms took " << tmpRunTime
1684 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
1688 if ((statisticalOptions.cdfStaccCompute() ) &&
1689 (statisticalOptions.cdfStaccNumEvalPositions() > 0)) {
1691 iRC = gettimeofday(&timevalTmp, NULL);
1692 if (m_env.subDisplayFile()) {
1693 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1694 <<
"\nComputing cdf statistical accuracy"
1698 std::vector<V*> cdfStaccEvalPositions(statisticalOptions.cdfStaccNumEvalPositions(),NULL);
1701 cdfStaccEvalPositions);
1703 std::vector<V*> cdfStaccValues(statisticalOptions.cdfStaccNumEvalPositions(),NULL);
1704 this->subCdfStacc(0,
1705 cdfStaccEvalPositions,
1710 if (m_env.subDisplayFile()) {
1711 *m_env.subDisplayFile() <<
"Chain cdf statistical accuracy took " << tmpRunTime
1720 if ((statisticalOptions.kdeCompute() ) &&
1721 (statisticalOptions.kdeNumEvalPositions() > 0)) {
1723 iRC = gettimeofday(&timevalTmp, NULL);
1724 if (m_env.subDisplayFile()) {
1725 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1726 <<
"\nComputing Kde"
1730 std::string subCoreName_GaussianKdePositions((std::string)(
"_GkdePosits_sub")+m_env.subIdString());
1731 std::string uniCoreName_GaussianKdePositions((std::string)(
"_unifGkdePosits_sub")+m_env.subIdString());
1732 if (m_env.numSubEnvironments() == 1) subCoreName_GaussianKdePositions = uniCoreName_GaussianKdePositions;
1734 std::string subCoreName_GaussianKdeScaleVec ((std::string)(
"_GkdeScalev_sub")+m_env.subIdString());
1735 std::string uniCoreName_GaussianKdeScaleVec ((std::string)(
"_unifGkdeScalev_sub")+m_env.subIdString());
1736 if (m_env.numSubEnvironments() == 1) subCoreName_GaussianKdeScaleVec = uniCoreName_GaussianKdeScaleVec;
1738 std::string subCoreName_GaussianKdeValues ((std::string)(
"_GkdeValues_sub")+m_env.subIdString());
1739 std::string uniCoreName_GaussianKdeValues ((std::string)(
"_unifGkdeValues_sub")+m_env.subIdString());
1740 if (m_env.numSubEnvironments() == 1) subCoreName_GaussianKdeValues = uniCoreName_GaussianKdeValues;
1742 V iqrVec(m_vectorSpace.zeroVector());
1743 this->subInterQuantileRange(0,
1746 V gaussianKdeScaleVec(m_vectorSpace.zeroVector());
1747 this->subScalesForKde(0,
1750 gaussianKdeScaleVec);
1752 std::vector<V*> kdeEvalPositions(statisticalOptions.kdeNumEvalPositions(),NULL);
1757 std::vector<V*> gaussianKdeDensities(statisticalOptions.kdeNumEvalPositions(),NULL);
1758 this->subGaussian1dKde(0,
1759 gaussianKdeScaleVec,
1761 gaussianKdeDensities);
1764 if (m_env.subDisplayFile()) {
1765 *m_env.subDisplayFile() <<
"\nComputed inter quantile ranges for chain '" << m_name <<
"'"
1771 *m_env.subDisplayFile() << line;
1773 sprintf(line,
"%9s%s",
1776 *m_env.subDisplayFile() << line;
1778 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1779 sprintf(line,
"\n%8.8s",
1780 m_vectorSpace.localComponentName(i).c_str() );
1781 *m_env.subDisplayFile() << line;
1783 sprintf(line,
"%2s%11.4e",
1786 *m_env.subDisplayFile() << line;
1788 *m_env.subDisplayFile() << std::endl;
1792 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() > 10)) {
1793 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeHistCdfstaccKde()"
1794 <<
", for chain '" << m_name <<
"'"
1795 <<
", about to write sub kde to ofstream with pointer = " << passedOfs
1799 std::ofstream& ofsvar = *passedOfs;
1800 ofsvar << m_name << subCoreName_GaussianKdePositions <<
" = zeros(" << this->vectorSizeLocal()
1801 <<
"," << kdeEvalPositions.size()
1804 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1805 for (
unsigned int j = 0; j < kdeEvalPositions.size(); ++j) {
1806 ofsvar << m_name << subCoreName_GaussianKdePositions <<
"(" << i+1
1808 <<
") = " << (*(kdeEvalPositions[j]))[i]
1814 ofsvar << m_name << subCoreName_GaussianKdeScaleVec <<
" = zeros(" << this->vectorSizeLocal()
1817 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1818 ofsvar << m_name << subCoreName_GaussianKdeScaleVec <<
"(" << i+1
1819 <<
") = " << gaussianKdeScaleVec[i]
1824 ofsvar << m_name << subCoreName_GaussianKdeValues <<
" = zeros(" << this->vectorSizeLocal()
1825 <<
"," << gaussianKdeDensities.size()
1828 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1829 for (
unsigned int j = 0; j < gaussianKdeDensities.size(); ++j) {
1830 ofsvar << m_name << subCoreName_GaussianKdeValues <<
"(" << i+1
1832 <<
") = " << (*(gaussianKdeDensities[j]))[i]
1839 for (
unsigned int i = 0; i < gaussianKdeDensities.size(); ++i) {
1840 if (gaussianKdeDensities[i] != NULL)
delete gaussianKdeDensities[i];
1842 for (
unsigned int i = 0; i < kdeEvalPositions.size(); ++i) {
1843 if (kdeEvalPositions[i] != NULL)
delete kdeEvalPositions[i];
1846 if ((
int) m_env.numSubEnvironments() > 1) {
1848 V unifiedIqrVec(m_vectorSpace.zeroVector());
1849 this->unifiedInterQuantileRange(0,
1853 V unifiedGaussianKdeScaleVec(m_vectorSpace.zeroVector());
1854 this->unifiedScalesForKde(0,
1857 unifiedGaussianKdeScaleVec);
1860 std::vector<V*> unifiedKdeEvalPositions(statisticalOptions.kdeNumEvalPositions(),NULL);
1862 unifiedStatsMaxPositions,
1863 unifiedKdeEvalPositions);
1865 std::vector<V*> unifiedGaussianKdeDensities(statisticalOptions.kdeNumEvalPositions(),NULL);
1866 this->unifiedGaussian1dKde(0,
1867 unifiedGaussianKdeScaleVec,
1868 unifiedKdeEvalPositions,
1869 unifiedGaussianKdeDensities);
1873 if (m_env.subDisplayFile()) {
1874 if (m_vectorSpace.numOfProcsForStorage() == 1) {
1875 if (m_env.inter0Rank() == 0) {
1876 *m_env.subDisplayFile() <<
"\nComputed unified inter quantile ranges for chain '" << m_name <<
"'"
1882 *m_env.subDisplayFile() << line;
1884 sprintf(line,
"%9s%s",
1887 *m_env.subDisplayFile() << line;
1889 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1890 sprintf(line,
"\n%8.8s",
1891 m_vectorSpace.localComponentName(i).c_str() );
1892 *m_env.subDisplayFile() << line;
1894 sprintf(line,
"%2s%11.4e",
1897 *m_env.subDisplayFile() << line;
1899 *m_env.subDisplayFile() << std::endl;
1903 queso_error_msg(
"unified iqr writing, parallel vectors not supported yet");
1908 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() > 10)) {
1909 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeHistCdfstaccKde()"
1910 <<
", for chain '" << m_name <<
"'"
1911 <<
", about to write unified kde to ofstream with pointer = " << passedOfs
1915 if (m_vectorSpace.numOfProcsForStorage() == 1) {
1916 if (m_env.inter0Rank() == 0) {
1917 std::ofstream& ofsvar = *passedOfs;
1918 ofsvar << m_name << uniCoreName_GaussianKdePositions <<
" = zeros(" << this->vectorSizeLocal()
1919 <<
"," << unifiedKdeEvalPositions.size()
1922 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() > 10)) {
1923 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeHistCdfstaccKde()"
1924 <<
", for chain '" << m_name <<
"'"
1925 <<
": just wrote '... = zeros(.,.);' line to output file, which has pointer = " << passedOfs
1928 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1929 for (
unsigned int j = 0; j < unifiedKdeEvalPositions.size(); ++j) {
1930 ofsvar << m_name << uniCoreName_GaussianKdePositions <<
"(" << i+1
1932 <<
") = " << (*(unifiedKdeEvalPositions[j]))[i]
1938 ofsvar << m_name << uniCoreName_GaussianKdeScaleVec <<
" = zeros(" << this->vectorSizeLocal()
1941 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1942 ofsvar << m_name << uniCoreName_GaussianKdeScaleVec <<
"(" << i+1
1943 <<
") = " << unifiedGaussianKdeScaleVec[i]
1948 ofsvar << m_name << uniCoreName_GaussianKdeValues <<
" = zeros(" << this->vectorSizeLocal()
1949 <<
"," << unifiedGaussianKdeDensities.size()
1952 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
1953 for (
unsigned int j = 0; j < unifiedGaussianKdeDensities.size(); ++j) {
1954 ofsvar << m_name << uniCoreName_GaussianKdeValues <<
"(" << i+1
1956 <<
") = " << (*(unifiedGaussianKdeDensities[j]))[i]
1964 queso_error_msg(
"unified Kde writing, parallel vectors not supported yet");
1968 for (
unsigned int i = 0; i < unifiedGaussianKdeDensities.size(); ++i) {
1969 if (unifiedGaussianKdeDensities[i] != NULL)
delete unifiedGaussianKdeDensities[i];
1971 for (
unsigned int i = 0; i < unifiedKdeEvalPositions.size(); ++i) {
1972 if (unifiedKdeEvalPositions[i] != NULL)
delete unifiedKdeEvalPositions[i];
1978 if (m_env.subDisplayFile()) {
1979 *m_env.subDisplayFile() <<
"Chain Kde took " << tmpRunTime
1985 if (m_env.subDisplayFile()) {
1986 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
1987 <<
"\n Finished computing histogram and/or cdf stacc and/or Kde for chain '" << m_name <<
"'"
1988 <<
"\n-----------------------------------------------------"
1997 template<
class V,
class M>
1999 BaseVectorSequence<V,M>::computeCovCorrMatrices(
2000 const SequenceStatisticalOptions& statisticalOptions,
2001 std::ofstream* passedOfs)
2004 computeCovCorrMatrices(statisticalOptions.m_ov, passedOfs);
2007 template<
class V,
class M>
2009 BaseVectorSequence<V,M>::computeCovCorrMatrices(
2010 const SsOptionsValues& statisticalOptions,
2011 std::ofstream* passedOfs)
2013 if (m_env.subDisplayFile()) {
2014 *m_env.subDisplayFile() <<
"\n"
2015 <<
"\n-----------------------------------------------------"
2016 <<
"\n Computing covariance and correlation matrices for chain '" << m_name <<
"' ..."
2017 <<
"\n-----------------------------------------------------"
2024 M* covarianceMatrix =
new M(m_env,
2025 m_vectorSpace.map(),
2026 m_vectorSpace.dimGlobal());
2027 M* correlationMatrix =
new M(m_env,
2028 m_vectorSpace.map(),
2029 m_vectorSpace.dimGlobal());
2033 this->subSequenceSize(),
2035 *correlationMatrix);
2037 if (m_env.subDisplayFile()) {
2038 if (m_vectorSpace.numOfProcsForStorage() == 1) {
2040 if (m_env.inter0Rank() == 0) {
2041 *m_env.subDisplayFile() <<
"\nBaseVectorSequence<V,M>::computeCovCorrMatrices"
2042 <<
", chain " << m_name
2043 <<
": contents of covariance matrix are\n" << *covarianceMatrix
2046 *m_env.subDisplayFile() <<
"\nBaseVectorSequence<V,M>::computeCovCorrMatrices"
2047 <<
", chain " << m_name
2048 <<
": contents of correlation matrix are\n" << *correlationMatrix
2057 delete correlationMatrix;
2058 delete covarianceMatrix;
2060 if (m_env.subDisplayFile()) {
2061 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2062 <<
"\n Finished computing covariance and correlation matrices for chain '" << m_name <<
"'"
2063 <<
"\n-----------------------------------------------------"
2070 #endif // #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
2076 #ifdef UQ_CODE_HAS_MONITORS
2077 template<
class V,
class M>
2079 BaseVectorSequence<V,M>::computeMeanEvolution(
2080 const SequenceStatisticalOptions& statisticalOptions,
2081 std::ofstream* passedOfs)
2084 computeMeanEvolution(statisticalOptions.m_ov, passedOfs);
2087 template<
class V,
class M>
2089 BaseVectorSequence<V,M>::computeMeanEvolution(
2090 const SsOptionsValues& statisticalOptions,
2091 std::ofstream* passedOfs)
2094 struct timeval timevalTmp;
2095 iRC = gettimeofday(&timevalTmp, NULL);
2096 double tmpRunTime = 0.;
2098 if (m_env.subDisplayFile()) {
2099 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2100 <<
"\nComputing mean evolution"
2104 unsigned int monitorPeriod = statisticalOptions.meanMonitorPeriod();
2105 unsigned int iMin = 0;
2106 unsigned int iMax = (
unsigned int) ( ((
double) this->subSequenceSize())/((double) monitorPeriod) );
2108 if (monitorPeriod == 1) {
2112 if (m_env.subDisplayFile()) {
2113 *m_env.subDisplayFile() <<
" Sub sequence size = " << this->subSequenceSize()
2114 <<
"\n Monitor period = " << monitorPeriod
2115 <<
"\n Number of monitoring positions = " << iMax
2119 this->subMeanMonitorAlloc(iMax);
2120 if (m_env.numSubEnvironments() > 1) {
2121 this->subMeanInter0MonitorAlloc(iMax);
2122 this->unifiedMeanMonitorAlloc(iMax);
2125 for (
unsigned int i = iMin; i < iMax; ++i) {
2126 unsigned int currentMonitoredFinalPosition = (i+1)*monitorPeriod - 1;
2127 V subMeanVec (m_vectorSpace.zeroVector());
2128 V subMeanCltStd(m_vectorSpace.zeroVector());
2129 this->subMeanMonitorRun(currentMonitoredFinalPosition,
2132 this->subMeanMonitorStore(i,
2133 currentMonitoredFinalPosition,
2137 if (m_env.numSubEnvironments() > 1) {
2138 V subMeanInter0Mean (m_vectorSpace.zeroVector());
2139 V subMeanInter0Clt95 (m_vectorSpace.zeroVector());
2140 V subMeanInter0Empirical90(m_vectorSpace.zeroVector());
2141 V subMeanInter0Min (m_vectorSpace.zeroVector());
2142 V subMeanInter0Max (m_vectorSpace.zeroVector());
2143 this->subMeanInter0MonitorRun(currentMonitoredFinalPosition,
2146 subMeanInter0Empirical90,
2149 this->subMeanInter0MonitorStore(i,
2150 currentMonitoredFinalPosition,
2153 subMeanInter0Empirical90,
2157 V unifiedMeanVec (m_vectorSpace.zeroVector());
2158 V unifiedMeanCltStd(m_vectorSpace.zeroVector());
2159 this->unifiedMeanMonitorRun(currentMonitoredFinalPosition,
2162 this->unifiedMeanMonitorStore(i,
2163 currentMonitoredFinalPosition,
2170 this->subMeanMonitorWrite(*passedOfs);
2171 if (m_env.numSubEnvironments() > 1) {
2172 this->subMeanInter0MonitorWrite(*passedOfs);
2173 this->unifiedMeanMonitorWrite(*passedOfs);
2177 this->subMeanMonitorFree();
2178 if (m_env.numSubEnvironments() > 1) {
2179 this->subMeanInter0MonitorFree();
2180 this->unifiedMeanMonitorFree();
2184 if (m_env.subDisplayFile()) {
2185 *m_env.subDisplayFile() <<
"Mean evolution took " << tmpRunTime
2192 #endif //#ifdef UQ_CODE_HAS_MONITORS
2199 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
2200 template<
class V,
class M>
2202 BaseVectorSequence<V,M>::computeBMM(
2203 const SequenceStatisticalOptions& statisticalOptions,
2204 const std::vector<unsigned int>& initialPosForStatistics,
2205 std::ofstream* passedOfs)
2208 computeMeanStacc(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2211 template<
class V,
class M>
2213 BaseVectorSequence<V,M>::computeMeanStacc(
2214 const SsOptionsValues& statisticalOptions,
2215 const std::vector<unsigned int>& initialPosForStatistics,
2216 std::ofstream* passedOfs)
2219 struct timeval timevalTmp;
2220 iRC = gettimeofday(&timevalTmp, NULL);
2221 double tmpRunTime = 0.;
2223 if (m_env.subDisplayFile()) {
2224 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2225 <<
"\nComputing variance of sample mean through BMM"
2229 if (m_env.subDisplayFile()) {
2230 *m_env.subDisplayFile() <<
"In BaseVectorSequence<V,M>::computeBMM(): lengths for batchs in BMM =";
2231 for (
unsigned int i = 0; i < statisticalOptions.bmmLengths().size(); ++i) {
2232 *m_env.subDisplayFile() <<
" " << statisticalOptions.bmmLengths()[i];
2234 *m_env.subDisplayFile() << std::endl;
2237 TwoDArray<V> _2dArrayOfBMM(initialPosForStatistics.size(),statisticalOptions.bmmLengths().size());
2238 for (
unsigned int i = 0; i < _2dArrayOfBMM.numRows(); ++i) {
2239 for (
unsigned int j = 0; j < _2dArrayOfBMM.numCols(); ++j) {
2240 _2dArrayOfBMM.setLocation(i,j,
new V(m_vectorSpace.zeroVector()) );
2243 V bmmVec(m_vectorSpace.zeroVector());
2244 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2245 unsigned int initialPos = initialPosForStatistics[initialPosId];
2246 for (
unsigned int batchLengthId = 0; batchLengthId < statisticalOptions.bmmLengths().size(); batchLengthId++) {
2247 unsigned int batchLength = statisticalOptions.bmmLengths()[batchLengthId];
2248 this->bmm(initialPos,
2251 _2dArrayOfBMM(initialPosId,batchLengthId) = bmmVec;
2255 if (m_env.subDisplayFile()) {
2256 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2257 *m_env.subDisplayFile() <<
"\nEstimated variance of sample mean, through batch means method, for subchain beginning at position " << initialPosForStatistics[initialPosId]
2258 <<
" (each column corresponds to a batch length)"
2264 *m_env.subDisplayFile() << line;
2265 for (
unsigned int batchLengthId = 0; batchLengthId < statisticalOptions.bmmLengths().size(); batchLengthId++) {
2266 sprintf(line,
"%10s%3d",
2268 statisticalOptions.bmmLengths()[batchLengthId]);
2269 *m_env.subDisplayFile() << line;
2272 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2273 sprintf(line,
"\n%9.9s",
2274 m_vectorSpace.localComponentName(i).c_str() );
2275 *m_env.subDisplayFile() << line;
2276 for (
unsigned int batchLengthId = 0; batchLengthId < statisticalOptions.bmmLengths().size(); batchLengthId++) {
2277 sprintf(line,
"%2s%11.4e",
2279 _2dArrayOfBMM(initialPosId,batchLengthId)[i]);
2280 *m_env.subDisplayFile() << line;
2283 *m_env.subDisplayFile() << std::endl;
2288 if (m_env.subDisplayFile()) {
2289 *m_env.subDisplayFile() <<
"Chain BMM took " << tmpRunTime
2297 template<
class V,
class M>
2299 BaseVectorSequence<V,M>::computeFFT(
2300 const SequenceStatisticalOptions& statisticalOptions,
2301 const std::vector<unsigned int>& initialPosForStatistics,
2302 std::ofstream* passedOfs)
2305 computeBMM(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2308 template<
class V,
class M>
2310 BaseVectorSequence<V,M>::computeBMM(
2311 const SsOptionsValues& statisticalOptions,
2312 const std::vector<unsigned int>& initialPosForStatistics,
2313 std::ofstream* passedOfs)
2316 struct timeval timevalTmp;
2317 iRC = gettimeofday(&timevalTmp, NULL);
2318 double tmpRunTime = 0.;
2320 if (m_env.subDisplayFile()) {
2321 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2322 <<
"\nComputing FFT of chain on parameter of id = " << statisticalOptions.fftParamId()
2326 std::vector<std::complex<double> > forwardResult(0,std::complex<double>(0.,0.));
2327 std::vector<std::complex<double> > inverseResult(0,std::complex<double>(0.,0.));
2328 Fft<std::complex<double> > fftObj(m_env);
2329 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2330 unsigned int initialPosition = initialPosForStatistics[initialPosId];
2331 this->fftForward(initialPosition,
2332 statisticalOptions.fftSize(),
2333 statisticalOptions.fftParamId(),
2336 if (statisticalOptions.fftWrite() && passedOfs) {
2337 std::ofstream& ofsvar = *passedOfs;
2338 ofsvar << m_name <<
"_fftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << 1
2339 <<
"," << forwardResult.size()
2342 for (
unsigned int j = 0; j < forwardResult.size(); ++j) {
2343 ofsvar << m_name <<
"_fftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << 1
2345 <<
") = " << forwardResult[j].real()
2346 <<
" + i*" << forwardResult[j].imag()
2352 if (statisticalOptions.fftTestInversion()) {
2353 fftObj.inverse(forwardResult,
2354 statisticalOptions.fftSize(),
2356 if (statisticalOptions.fftWrite() && passedOfs) {
2357 std::ofstream& ofsvar = *passedOfs;
2358 ofsvar << m_name <<
"_iftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << 1
2359 <<
"," << inverseResult.size()
2362 for (
unsigned int j = 0; j < inverseResult.size(); ++j) {
2363 ofsvar << m_name <<
"_iftInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << 1
2365 <<
") = " << inverseResult[j].real()
2366 <<
" + i*" << inverseResult[j].imag()
2375 if (m_env.subDisplayFile()) {
2376 *m_env.subDisplayFile() <<
"Chain FFT took " << tmpRunTime
2384 template<
class V,
class M>
2386 BaseVectorSequence<V,M>::computePSD(
2387 const SequenceStatisticalOptions& statisticalOptions,
2388 const std::vector<unsigned int>& initialPosForStatistics,
2389 std::ofstream* passedOfs)
2392 computeFFT(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2395 template<
class V,
class M>
2397 BaseVectorSequence<V,M>::computeFFT(
2398 const SsOptionsValues& statisticalOptions,
2399 const std::vector<unsigned int>& initialPosForStatistics,
2400 std::ofstream* passedOfs)
2403 struct timeval timevalTmp;
2404 iRC = gettimeofday(&timevalTmp, NULL);
2405 double tmpRunTime = 0.;
2407 if (m_env.subDisplayFile()) {
2408 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2409 <<
"\nComputing PSD of chain on parameter of id = " << statisticalOptions.psdParamId()
2413 std::vector<double> psdResult(0,0.);
2414 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2415 unsigned int initialPosition = initialPosForStatistics[initialPosId];
2416 this->psd(initialPosition,
2417 statisticalOptions.psdNumBlocks(),
2418 statisticalOptions.psdHopSizeRatio(),
2419 statisticalOptions.psdParamId(),
2422 if (statisticalOptions.psdWrite() && passedOfs) {
2423 std::ofstream& ofsvar = *passedOfs;
2424 ofsvar << m_name <<
"_psdInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << 1
2425 <<
"," << psdResult.size()
2428 for (
unsigned int j = 0; j < psdResult.size(); ++j) {
2429 ofsvar << m_name <<
"_psdInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << 1
2431 <<
") = " << psdResult[j]
2439 if (m_env.subDisplayFile()) {
2440 *m_env.subDisplayFile() <<
"Chain PSD took " << tmpRunTime
2448 template<
class V,
class M>
2450 BaseVectorSequence<V,M>::computePSDAtZero(
2451 const SequenceStatisticalOptions& statisticalOptions,
2452 const std::vector<unsigned int>& initialPosForStatistics,
2453 std::ofstream* passedOfs)
2456 computePSD(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2459 template<
class V,
class M>
2461 BaseVectorSequence<V,M>::computePSD(
2462 const SsOptionsValues& statisticalOptions,
2463 const std::vector<unsigned int>& initialPosForStatistics,
2464 std::ofstream* passedOfs)
2467 struct timeval timevalTmp;
2468 iRC = gettimeofday(&timevalTmp, NULL);
2469 double tmpRunTime = 0.;
2471 if (m_env.subDisplayFile()) {
2472 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2473 <<
"\nComputing PSD at frequency zero for all parameters"
2477 TwoDArray<V> _2dArrayOfPSDAtZero(initialPosForStatistics.size(),statisticalOptions.psdAtZeroNumBlocks().size());
2478 for (
unsigned int i = 0; i < _2dArrayOfPSDAtZero.numRows(); ++i) {
2479 for (
unsigned int j = 0; j < _2dArrayOfPSDAtZero.numCols(); ++j) {
2480 _2dArrayOfPSDAtZero.setLocation(i,j,
new V(m_vectorSpace.zeroVector()) );
2483 V psdVec(m_vectorSpace.zeroVector());
2484 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2485 unsigned int initialPosition = initialPosForStatistics[initialPosId];
2486 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2487 unsigned int numBlocks = statisticalOptions.psdAtZeroNumBlocks()[numBlocksId];
2488 this->psdAtZero(initialPosition,
2490 statisticalOptions.psdAtZeroHopSizeRatio(),
2492 _2dArrayOfPSDAtZero(initialPosId,numBlocksId) = psdVec;
2497 if ((statisticalOptions.psdAtZeroDisplay()) && (m_env.subDisplayFile())) {
2498 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2499 unsigned int initialPos = initialPosForStatistics[initialPosId];
2500 *m_env.subDisplayFile() <<
"\nComputed PSD at frequency zero for subchain beginning at position " << initialPos
2501 <<
", so effective data size = " << this->subSequenceSize() - initialPos
2502 <<
" (each column corresponds to a number of blocks)"
2508 *m_env.subDisplayFile() << line;
2509 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2510 sprintf(line,
"%10s%3d",
2512 statisticalOptions.psdAtZeroNumBlocks()[numBlocksId]);
2513 *m_env.subDisplayFile() << line;
2516 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2517 sprintf(line,
"\n%9.9s",
2518 m_vectorSpace.localComponentName(i).c_str() );
2519 *m_env.subDisplayFile() << line;
2520 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2521 sprintf(line,
"%2s%11.4e",
2523 _2dArrayOfPSDAtZero(initialPosId,numBlocksId)[i]);
2524 *m_env.subDisplayFile() << line;
2527 *m_env.subDisplayFile() << std::endl;
2532 if ( (m_env.subDisplayFile())) {
2533 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2534 unsigned int initialPos = initialPosForStatistics[initialPosId];
2535 *m_env.subDisplayFile() <<
"\nEstimated variance of sample mean, through psd, for subchain beginning at position " << initialPos
2536 <<
", so effective data size = " << this->subSequenceSize() - initialPos
2537 <<
" (each column corresponds to a number of blocks)"
2543 *m_env.subDisplayFile() << line;
2544 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2545 sprintf(line,
"%10s%3d",
2547 statisticalOptions.psdAtZeroNumBlocks()[numBlocksId]);
2548 *m_env.subDisplayFile() << line;
2551 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2552 sprintf(line,
"\n%9.9s",
2553 m_vectorSpace.localComponentName(i).c_str() );
2554 *m_env.subDisplayFile() << line;
2555 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2556 sprintf(line,
"%2s%11.4e",
2558 2.*M_PI*_2dArrayOfPSDAtZero(initialPosId,numBlocksId)[i]/(
double) (this->subSequenceSize() - initialPos));
2559 *m_env.subDisplayFile() << line;
2562 *m_env.subDisplayFile() << std::endl;
2567 if (m_env.subDisplayFile()) {
2568 *m_env.subDisplayFile() <<
"Chain PSD at frequency zero took " << tmpRunTime
2574 if (statisticalOptions.psdAtZeroWrite() && passedOfs) {
2575 std::ofstream& ofsvar = *passedOfs;
2576 ofsvar << m_name <<
"_psdAtZeroNumBlocks_sub" << m_env.subIdString() <<
" = zeros(" << 1
2577 <<
"," << statisticalOptions.psdAtZeroNumBlocks().size()
2580 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2581 ofsvar << m_name <<
"_psdAtZeroNumBlocks_sub" << m_env.subIdString() <<
"(" << 1
2582 <<
"," << numBlocksId+1
2583 <<
") = " << statisticalOptions.psdAtZeroNumBlocks()[numBlocksId]
2588 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2589 ofsvar << m_name <<
"_psdAtZeroInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
" = zeros(" << this->vectorSizeLocal()
2590 <<
"," << statisticalOptions.psdAtZeroNumBlocks().size()
2593 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2594 for (
unsigned int numBlocksId = 0; numBlocksId < statisticalOptions.psdAtZeroNumBlocks().size(); numBlocksId++) {
2595 ofsvar << m_name <<
"_psdAtZeroInitPos" << initialPosForStatistics[initialPosId] <<
"_sub" << m_env.subIdString() <<
"(" << i+1
2596 <<
"," << numBlocksId+1
2597 <<
") = " << _2dArrayOfPSDAtZero(initialPosId,numBlocksId)[i]
2608 template<
class V,
class M>
2610 BaseVectorSequence<V,M>::computeGeweke(
2611 const SequenceStatisticalOptions& statisticalOptions,
2612 const std::vector<unsigned int>& initialPosForStatistics,
2613 std::ofstream* passedOfs)
2616 computePSDAtZero(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2619 template<
class V,
class M>
2621 BaseVectorSequence<V,M>::computePSDAtZero(
2622 const SsOptionsValues& statisticalOptions,
2623 const std::vector<unsigned int>& initialPosForStatistics,
2624 std::ofstream* passedOfs)
2627 struct timeval timevalTmp;
2628 iRC = gettimeofday(&timevalTmp, NULL);
2629 double tmpRunTime = 0.;
2631 if (m_env.subDisplayFile()) {
2632 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2633 <<
"\nComputing Geweke coefficients"
2637 std::vector<V*> vectorOfGeweke(initialPosForStatistics.size(),NULL);
2638 V gewVec(m_vectorSpace.zeroVector());
2639 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2640 unsigned int initialPosition = initialPosForStatistics[initialPosId];
2641 this->geweke(initialPosition,
2642 statisticalOptions.gewekeNaRatio(),
2643 statisticalOptions.gewekeNbRatio(),
2645 vectorOfGeweke[initialPosId] =
new V(gewVec);
2648 if (m_env.subDisplayFile()) {
2649 *m_env.subDisplayFile() <<
"\nComputed Geweke coefficients with 10% and 50% percentages"
2650 <<
" (each column corresponds to a different initial position on the full chain)"
2656 *m_env.subDisplayFile() << line;
2657 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2658 sprintf(line,
"%10s%3d",
2660 initialPosForStatistics[initialPosId]);
2661 *m_env.subDisplayFile() << line;
2664 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2665 sprintf(line,
"\n%9.9s",
2666 m_vectorSpace.localComponentName(i).c_str() );
2667 *m_env.subDisplayFile() << line;
2668 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2669 sprintf(line,
"%2s%11.4e",
2671 (*(vectorOfGeweke[initialPosId]))[i]);
2672 *m_env.subDisplayFile() << line;
2675 *m_env.subDisplayFile() << std::endl;
2679 if (m_env.subDisplayFile()) {
2680 *m_env.subDisplayFile() <<
"Chain Geweke took " << tmpRunTime
2688 template<
class V,
class M>
2690 BaseVectorSequence<V,M>::computeMeanStacc(
2691 const SequenceStatisticalOptions& statisticalOptions,
2692 const std::vector<unsigned int>& initialPosForStatistics,
2693 std::ofstream* passedOfs)
2696 computeGeweke(statisticalOptions.m_ov, initialPosForStatistics, passedOfs);
2699 template<
class V,
class M>
2701 BaseVectorSequence<V,M>::computeGeweke(
2702 const SsOptionsValues& statisticalOptions,
2703 const std::vector<unsigned int>& initialPosForStatistics,
2704 std::ofstream* passedOfs)
2707 struct timeval timevalTmp;
2708 iRC = gettimeofday(&timevalTmp, NULL);
2709 double tmpRunTime = 0.;
2711 if (m_env.subDisplayFile()) {
2712 *m_env.subDisplayFile() <<
"\n-----------------------------------------------------"
2713 <<
"\nComputing mean statistical accuracy"
2717 std::vector<V*> vectorOfMeanStacc(initialPosForStatistics.size(),NULL);
2718 V meanStaccVec(m_vectorSpace.zeroVector());
2719 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2720 unsigned int initialPosition = initialPosForStatistics[initialPosId];
2721 this->meanStacc(initialPosition,
2723 vectorOfMeanStacc[initialPosId] =
new V(meanStaccVec);
2726 if (m_env.subDisplayFile()) {
2727 *m_env.subDisplayFile() <<
"\nComputed mean statistical accuracy"
2728 <<
" (each column corresponds to a different initial position on the full chain)"
2734 *m_env.subDisplayFile() << line;
2735 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2736 sprintf(line,
"%10s%3d",
2738 initialPosForStatistics[initialPosId]);
2739 *m_env.subDisplayFile() << line;
2742 for (
unsigned int i = 0; i < this->vectorSizeLocal() ; ++i) {
2743 sprintf(line,
"\n%9.9s",
2744 m_vectorSpace.localComponentName(i).c_str() );
2745 *m_env.subDisplayFile() << line;
2746 for (
unsigned int initialPosId = 0; initialPosId < initialPosForStatistics.size(); initialPosId++) {
2747 sprintf(line,
"%2s%11.4e",
2749 (*(vectorOfMeanStacc[initialPosId]))[i]);
2750 *m_env.subDisplayFile() << line;
2753 *m_env.subDisplayFile() << std::endl;
2757 if (m_env.subDisplayFile()) {
2758 *m_env.subDisplayFile() <<
"Chain mean statistical accuracy took " << tmpRunTime
2765 #endif // #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
2771 template <
class P_V,
class P_M,
class Q_V,
class Q_M>
2776 unsigned int subNumSamples,
2791 queso_require_msg(!((numRowsLocal != pqCovMatrix.numRowsLocal()) || (numCols != pqCovMatrix.numCols())),
"inconsistent dimensions for covariance matrix");
2793 queso_require_msg(!((numRowsLocal != pqCorrMatrix.numRowsLocal()) || (numCols != pqCorrMatrix.numCols())),
"inconsistent dimensions for correlation matrix");
2809 for (
unsigned i = 0; i < numRowsLocal; ++i) {
2810 for (
unsigned j = 0; j < numCols; ++j) {
2811 pqCovMatrix(i,j) = 0.;
2814 for (
unsigned k = 0;
k < subNumSamples; ++
k) {
2817 tmpP -= unifiedMeanP;
2820 tmpQ -= unifiedMeanQ;
2822 for (
unsigned i = 0; i < numRowsLocal; ++i) {
2823 for (
unsigned j = 0; j < numCols; ++j) {
2824 pqCovMatrix(i,j) += tmpP[i]*tmpQ[j];
2834 unifiedSampleVarianceP);
2840 unifiedSampleVarianceQ);
2843 if (useOnlyInter0Comm) {
2845 unsigned int unifiedNumSamples = 0;
2847 "ComputeCovCorrMatricesBetweenVectorSequences()",
2848 "failed MPI.Allreduce() for subNumSamples");
2850 for (
unsigned i = 0; i < numRowsLocal; ++i) {
2851 for (
unsigned j = 0; j < numCols; ++j) {
2854 "ComputeCovCorrMatricesBetweenVectorSequences()",
2855 "failed MPI.Allreduce() for a matrix position");
2856 pqCovMatrix(i,j) = aux/((double) (unifiedNumSamples-1));
2860 for (
unsigned i = 0; i < numRowsLocal; ++i) {
2861 for (
unsigned j = 0; j < numCols; ++j) {
2862 pqCorrMatrix(i,j) = pqCovMatrix(i,j)/std::sqrt(unifiedSampleVarianceP[i])/std::sqrt(unifiedSampleVarianceQ[j]);
2863 if (((pqCorrMatrix(i,j) + 1.) < -1.e-8) ||
2864 ((pqCorrMatrix(i,j) - 1.) > 1.e-8)) {
2866 std::cerr <<
"In ComputeCovCorrMatricesBetweenVectorSequences()"
2870 <<
", pqCorrMatrix(i,j)+1 = " << pqCorrMatrix(i,j)+1.
2871 <<
", pqCorrMatrix(i,j)-1 = " << pqCorrMatrix(i,j)-1.
2877 (pqCorrMatrix(i,j), -1. - 1.e-8,
2878 "computed correlation is out of range");
2880 (pqCorrMatrix(i,j), 1. + 1.e-8,
2881 "computed correlation is out of range");
unsigned int dimLocal() const
const V & unifiedMaxPlain() const
Finds the maximum value of the unified sequence.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const V & unifiedMeanPlain() const
Finds the mean value of the unified sequence.
Class for matrix operations using GSL library.
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.
double subPositionsOfMaximum(const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &subPositionsOfMaximum)
Finds the positions where the maximum element occurs in the sub-sequence.
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
void MiscComputePositionsBetweenMinMax(V minValues, V maxValues, std::vector< V * > &positions)
#define queso_require_less_equal_msg(expr1, expr2, msg)
const VectorSpace< V, M > & m_vectorSpace
const V & unifiedMedianPlain() const
Finds the median value of the unified sequence.
#define queso_error_msg(msg)
void ComputeCovCorrMatricesBetweenVectorSequences(const BaseVectorSequence< P_V, P_M > &subPSeq, const BaseVectorSequence< Q_V, Q_M > &subQSeq, unsigned int subNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
const T & subMaxPlain() const
Finds the maximum value of the sub-sequence of scalars.
int inter0Rank() const
Returns the process inter0 rank.
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.
const V & zeroVector() const
Returns a vector filled with zeros.
unsigned int dimGlobal() const
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 ...
#define queso_require_equal_to_msg(expr1, expr2, msg)
void clear()
Reset the values and the size of the sequence of vectors.
double MiscGetEllapsedSeconds(struct timeval *timeval0)
const V & subSampleVariancePlain() const
Finds the variance of a sample of the sub-sequence.
#define queso_require_msg(asserted, msg)
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...
BaseVectorSequence(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
const MpiComm & inter0Comm() const
Access function for MpiComm inter0-communicator.
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.
#define queso_deprecated()
virtual void resizeSequence(unsigned int newSubSequenceSize)=0
Resize the sequence. 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...
#define queso_require_greater_equal_msg(expr1, expr2, msg)
virtual ~BaseVectorSequence()
Destructor.
Class for a Fast Fourier Transform (FFT) algorithm.
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...
int worldRank() const
Returns the process world rank.
void copy(const BaseVectorSequence< V, M > &src)
Copies vector sequence src to this.
A class representing a vector space.
virtual unsigned int subSequenceSize() const =0
Size of the sub-sequence of vectors. See template specialization.
unsigned int numOfProcsForStorage() const
Returns total number of processes.
unsigned int subSequenceSize() const
Size of the sub-sequence of scalars.
#define RawValue_MPI_DOUBLE
void Allreduce(void *sendbuf, void *recvbuf, int count, RawType_MPI_Datatype datatype, RawType_MPI_Op op, const char *whereMsg, const char *whatMsg) const
Combines values from all processes and distributes the result back to all processes.
#define RawValue_MPI_UNSIGNED
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.
Base class for handling vector and array samples (sequence of vectors or arrays). ...
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.