MUQ  0.4.3
muq::SamplingAlgorithms::DistributedCollection Class Reference

#include <DistributedCollection.h>

Inheritance diagram for muq::SamplingAlgorithms::DistributedCollection:

Detailed Description

Definition at line 18 of file DistributedCollection.h.

Public Member Functions

 DistributedCollection (std::shared_ptr< SampleCollection > collection, std::shared_ptr< parcer::Communicator > comm)
 
virtual ~DistributedCollection ()=default
 
virtual void Add (std::shared_ptr< SamplingState > newSamp) override
 Add a sample that is stored on this processor. More...
 
std::shared_ptr< SamplingStateLocalAt (unsigned i)
 Get the local state at the \(i^{th}\) index. More...
 
const std::shared_ptr< SamplingStateLocalAt (unsigned i) const
 Get the local state at the \(i^{th}\) index. More...
 
std::shared_ptr< SamplingStateGlobalAt (unsigned i)
 Get the global state at the \(i^{th}\) index. More...
 
const std::shared_ptr< SamplingStateGlobalAt (unsigned i) const
 Get the global state at the \(i^{th}\) index. More...
 
virtual std::shared_ptr< SamplingStateat (unsigned i) override
 Get the local state at the \(i^{th}\) index. More...
 
virtual const std::shared_ptr< SamplingStateat (unsigned i) const override
 Get the local state at the \(i^{th}\) index. More...
 
unsigned int LocalSize () const
 The number of samples stored locally. More...
 
unsigned int GlobalSize () const
 The total number of samples. More...
 
virtual unsigned int size () const override
 The total number of samples. More...
 
Eigen::VectorXd LocalCentralMoment (unsigned order, int blockDim=-1) const
 Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order. More...
 
Eigen::VectorXd GlobalCentralMoment (unsigned order, int blockDim=-1) const
 Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order. More...
 
virtual Eigen::VectorXd CentralMoment (unsigned order, int blockDim=-1) const override
 Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order. More...
 
Eigen::VectorXd LocalMean (int blockDim=-1) const
 Compute the mean using only local samples. More...
 
Eigen::VectorXd GlobalMean (int blockDim=-1) const
 Compute the mean using all of the samples. More...
 
virtual Eigen::VectorXd Mean (int blockDim=-1) const override
 Compute the mean using all of the samples. More...
 
Eigen::VectorXd LocalVariance (int blockDim=-1) const
 Compute the variance using only local samples. More...
 
Eigen::VectorXd GlobalVariance (int blockDim=-1) const
 Compute the variance using all of the samples. More...
 
virtual Eigen::VectorXd Variance (int blockDim=-1) const override
 Compute the variance using all of the samples. More...
 
Eigen::MatrixXd LocalCovariance (int blockDim=-1) const
 Compute the covariance using only local samples. More...
 
Eigen::MatrixXd GlobalCovariance (int blockDim=-1) const
 Compute the covariance using all of the samples. More...
 
virtual Eigen::MatrixXd Covariance (int blockDim=-1) const override
 Compute the covariance using all of the samples. More...
 
Eigen::VectorXd LocalESS (int blockDim=-1) const
 Compute the ESS using only local samples. More...
 
Eigen::VectorXd GlobalESS (int blockDim=-1) const
 Compute the ESS using all of the samples. More...
 
virtual Eigen::VectorXd ESS (int blockDim=-1) const override
 Compute the ESS using all of the samples. More...
 
Eigen::MatrixXd AsLocalMatrix (int blockDim=-1) const
 Return all of the samples on the local processor as a matrix. More...
 
Eigen::MatrixXd AsGlobalMatrix (int blockDim=-1) const
 Return all of the samples as a matrix. More...
 
virtual Eigen::MatrixXd AsMatrix (int blockDim=-1) const override
 Return all of the samples as a matrix. More...
 
Eigen::VectorXd LocalWeights () const
 Return all of the weights on this processor as a vector. More...
 
Eigen::VectorXd GlobalWeights () const
 Return all of the weights as a vector. More...
 
virtual Eigen::VectorXd Weights () const override
 Return all of the weights as a vector. More...
 
virtual void WriteToFile (std::string const &filename, std::string const &dataset="/") const override
 
Eigen::VectorXd GlobalExpectedValue (std::shared_ptr< muq::Modeling::ModPiece > const &f, std::vector< std::string > const &metains=std::vector< std::string >()) const
 
Eigen::VectorXd LocalExpectedValue (std::shared_ptr< muq::Modeling::ModPiece > const &f, std::vector< std::string > const &metains=std::vector< std::string >()) const
 
virtual Eigen::VectorXd ExpectedValue (std::shared_ptr< muq::Modeling::ModPiece > const &f, std::vector< std::string > const &metains=std::vector< std::string >()) const override
 
- Public Member Functions inherited from muq::SamplingAlgorithms::SampleCollection
 SampleCollection ()=default
 
virtual ~SampleCollection ()=default
 
virtual std::shared_ptr< SampleCollectionhead (unsigned int N) const
 
virtual std::shared_ptr< SampleCollectiontail (unsigned int N) const
 
virtual std::shared_ptr< SampleCollectionsegment (unsigned int startInd, unsigned int length, unsigned int skipBy=1) const
 
virtual const std::shared_ptr< SamplingStateback () const
 
virtual Eigen::VectorXd CentralMoment (unsigned order, Eigen::VectorXd const &mean, int blockNum=-1) const override
 Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order given that we already know the mean. More...
 
virtual Eigen::VectorXd CentralMoment (unsigned int order, int blockNum=-1) const override
 
virtual Eigen::MatrixXd Covariance (Eigen::VectorXd const &mean, int blockInd=-1) const override
 
virtual std::vector< Eigen::MatrixXd > RunningCovariance (int blockInd=-1) const
 
virtual std::vector< Eigen::MatrixXd > RunningCovariance (Eigen::VectorXd const &mean, int blockInd=-1) const
 
virtual Eigen::VectorXd ESS (std::string const &method="Batch") const override
 Returns the effective sample size of the samples. More...
 
virtual Eigen::VectorXd ESS (int blockDim, std::string const &method) const override
 
Eigen::VectorXd BatchESS (int blockInd=-1, int batchSize=-1, int overlap=-1) const
 
double MultiBatchESS (int blockInd=-1, int batchSize=-1, int overlap=-1) const
 
virtual Eigen::VectorXd StandardError (int blockInd, std::string const &method) const override
 
virtual Eigen::VectorXd StandardError (int blockInd) const override
 
virtual Eigen::VectorXd StandardError (std::string const &method="Batch") const override
 
virtual Eigen::VectorXd BatchError (int blockInd=-1, int batchSize=-1, int overlap=-1) const
 
virtual Eigen::VectorXd MultiBatchError (int blockInd=-1, int batchSize=-1, int overlap=-1) const
 
virtual Eigen::VectorXd Rhat (int blockDim, unsigned int numSegments=4, boost::property_tree::ptree options=boost::property_tree::ptree()) const
 
virtual Eigen::VectorXd Rhat (unsigned int numSegments=4, boost::property_tree::ptree options=boost::property_tree::ptree()) const
 
- Public Member Functions inherited from muq::SamplingAlgorithms::SampleEstimator
virtual ~SampleEstimator ()=default
 
virtual unsigned int BlockSize (int blockInd) const =0
 
virtual unsigned int NumBlocks () const =0
 
virtual Eigen::VectorXd CentralMoment (unsigned int order, Eigen::VectorXd const &mean, int blockNum=-1) const
 
virtual Eigen::VectorXd StandardizedMoment (unsigned int order, int blockInd=-1) const
 
virtual Eigen::VectorXd StandardizedMoment (unsigned int order, Eigen::VectorXd const &mean, int blockInd=-1) const
 
virtual Eigen::VectorXd StandardizedMoment (unsigned int order, Eigen::VectorXd const &mean, Eigen::VectorXd const &stdDev, int blockInd=-1) const
 
virtual Eigen::VectorXd Variance (Eigen::VectorXd const &mean, int blockInd=-1) const
 
virtual Eigen::VectorXd Skewness (int blockInd=-1) const
 
virtual Eigen::VectorXd Skewness (Eigen::VectorXd const &mean, int blockInd=-1) const
 
virtual Eigen::VectorXd Skewness (Eigen::VectorXd const &mean, Eigen::VectorXd const &stdDev, int blockInd=-1) const
 
virtual Eigen::VectorXd Kurtosis (int blockInd=-1) const
 
virtual Eigen::VectorXd Kurtosis (Eigen::VectorXd const &mean, int blockInd=-1) const
 
virtual Eigen::VectorXd Kurtosis (Eigen::VectorXd const &mean, Eigen::VectorXd const &stdDev, int blockInd=-1) const
 

Additional Inherited Members

- Static Public Member Functions inherited from muq::SamplingAlgorithms::SampleCollection
static std::shared_ptr< SampleCollectionFromMatrix (Eigen::MatrixXd const &samps)
 

Constructor & Destructor Documentation

◆ DistributedCollection()

DistributedCollection::DistributedCollection ( std::shared_ptr< SampleCollection collection,
std::shared_ptr< parcer::Communicator >  comm 
)

Definition at line 12 of file DistributedCollection.cpp.

◆ ~DistributedCollection()

virtual muq::SamplingAlgorithms::DistributedCollection::~DistributedCollection ( )
virtualdefault

Member Function Documentation

◆ Add()

void DistributedCollection::Add ( std::shared_ptr< SamplingState newSamp)
overridevirtual

Add a sample that is stored on this processor.

Parameters
[in]newSampThe sample to be added

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 14 of file DistributedCollection.cpp.

References collection.

◆ AsGlobalMatrix()

Eigen::MatrixXd DistributedCollection::AsGlobalMatrix ( int  blockDim = -1) const

Return all of the samples as a matrix.

Parameters
[in]blockDimReturn the samples of this block
Returns
Each column is a sample

Definition at line 137 of file DistributedCollection.cpp.

References AsLocalMatrix(), comm, GlobalSize(), and LocalSize().

Referenced by AsMatrix().

◆ AsLocalMatrix()

Eigen::MatrixXd DistributedCollection::AsLocalMatrix ( int  blockDim = -1) const

Return all of the samples on the local processor as a matrix.

Parameters
[in]blockDimReturn the samples of this block
Returns
Each column is a sample

Definition at line 135 of file DistributedCollection.cpp.

References collection.

Referenced by AsGlobalMatrix().

◆ AsMatrix()

Eigen::MatrixXd DistributedCollection::AsMatrix ( int  blockDim = -1) const
overridevirtual

Return all of the samples as a matrix.

Parameters
[in]blockDimReturn the samples of this block
Returns
Each column is a sample

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 158 of file DistributedCollection.cpp.

References AsGlobalMatrix().

◆ at() [1/2]

const std::shared_ptr< SamplingState > DistributedCollection::at ( unsigned  i) const
overridevirtual

Get the local state at the \(i^{th}\) index.

Parameters
[in]iThe local index

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 20 of file DistributedCollection.cpp.

References GlobalAt().

◆ at() [2/2]

std::shared_ptr< SamplingState > DistributedCollection::at ( unsigned  i)
overridevirtual

Get the local state at the \(i^{th}\) index.

Parameters
[in]iThe local index

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 18 of file DistributedCollection.cpp.

References GlobalAt().

◆ CentralMoment()

Eigen::VectorXd DistributedCollection::CentralMoment ( unsigned  order,
int  blockDim = -1 
) const
overridevirtual

Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order.

Defaults to using all of the samples.

Parameters
[in]orderThe order of the central moment
[in]blockDimCompute the central moment of this block
Returns
The central moment using all of the samples

Definition at line 96 of file DistributedCollection.cpp.

References GlobalCentralMoment().

◆ Covariance()

Eigen::MatrixXd DistributedCollection::Covariance ( int  blockDim = -1) const
overridevirtual

Compute the covariance using all of the samples.

Defaults to using the global covariance.

Parameters
[in]blockDimCompute the covariance of this block
Returns
The global covariance

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 114 of file DistributedCollection.cpp.

References GlobalCovariance().

◆ ESS()

Eigen::VectorXd DistributedCollection::ESS ( int  blockDim = -1) const
overridevirtual

Compute the ESS using all of the samples.

Defaults to using the global ESS.

Parameters
[in]blockDimCompute the ESS of this block
Returns
The global ESS

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 133 of file DistributedCollection.cpp.

References GlobalESS().

◆ ExpectedValue()

Eigen::VectorXd DistributedCollection::ExpectedValue ( std::shared_ptr< muq::Modeling::ModPiece > const &  f,
std::vector< std::string > const &  metains = std::vector< std::string >() 
) const
overridevirtual

Using samples of \(x\) stored in this sample collection, this function approximates the expected value of \(f(x)\) for some function \(f\) defined as a muq::Modeling::ModPiece. The output is a vector containing the expected value of \(f\).

Implements muq::SamplingAlgorithms::SampleEstimator.

Definition at line 211 of file DistributedCollection.cpp.

References GlobalExpectedValue().

◆ GlobalAt() [1/2]

std::shared_ptr< SamplingState > DistributedCollection::GlobalAt ( unsigned  i)

Get the global state at the \(i^{th}\) index.

Parameters
[in]iThe global index

Definition at line 32 of file DistributedCollection.cpp.

References comm, GlobalSize(), LocalAt(), LocalSize(), and size().

Referenced by at().

◆ GlobalAt() [2/2]

const std::shared_ptr< SamplingState > DistributedCollection::GlobalAt ( unsigned  i) const

Get the global state at the \(i^{th}\) index.

Parameters
[in]iThe global index

Definition at line 54 of file DistributedCollection.cpp.

References comm, GlobalSize(), LocalAt(), LocalSize(), and size().

◆ GlobalCentralMoment()

Eigen::VectorXd DistributedCollection::GlobalCentralMoment ( unsigned  order,
int  blockDim = -1 
) const

Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order.

Parameters
[in]orderThe order of the central moment
[in]blockDimCompute the central moment of this block
Returns
The central moment using all of the samples

Definition at line 94 of file DistributedCollection.cpp.

References GlobalEigenMean(), and LocalCentralMoment().

Referenced by CentralMoment().

◆ GlobalCovariance()

Eigen::MatrixXd DistributedCollection::GlobalCovariance ( int  blockDim = -1) const

Compute the covariance using all of the samples.

Parameters
[in]blockDimCompute the covariance of this block
Returns
The global covariance

Definition at line 112 of file DistributedCollection.cpp.

References GlobalEigenMean(), and LocalCovariance().

Referenced by Covariance().

◆ GlobalEigenMean()

template<class scalar , int rows, int cols, int options, int maxRows, int maxCols>
Eigen::Matrix<scalar, rows, cols, options, maxRows, maxCols> muq::SamplingAlgorithms::DistributedCollection::GlobalEigenMean ( Eigen::Matrix< scalar, rows, cols, options, maxRows, maxCols > const &  local) const
inlineprivate

Definition at line 257 of file DistributedCollection.h.

References comm.

Referenced by GlobalCentralMoment(), GlobalCovariance(), GlobalMean(), and GlobalVariance().

◆ GlobalESS()

Eigen::VectorXd DistributedCollection::GlobalESS ( int  blockDim = -1) const

Compute the ESS using all of the samples.

Parameters
[in]blockDimCompute the ESS of this block
Returns
The global ESS

Definition at line 118 of file DistributedCollection.cpp.

References comm, and LocalESS().

Referenced by ESS().

◆ GlobalExpectedValue()

Eigen::VectorXd DistributedCollection::GlobalExpectedValue ( std::shared_ptr< muq::Modeling::ModPiece > const &  f,
std::vector< std::string > const &  metains = std::vector<std::string>() 
) const

Definition at line 191 of file DistributedCollection.cpp.

References comm, and LocalExpectedValue().

Referenced by ExpectedValue().

◆ GlobalMean()

Eigen::VectorXd DistributedCollection::GlobalMean ( int  blockDim = -1) const

Compute the mean using all of the samples.

Parameters
[in]blockDimCompute the mean of this block
Returns
The global mean

Definition at line 100 of file DistributedCollection.cpp.

References GlobalEigenMean(), and LocalMean().

Referenced by LocalCentralMoment(), LocalCovariance(), and Mean().

◆ GlobalSize()

unsigned int DistributedCollection::GlobalSize ( ) const

The total number of samples.

Returns
The sum of the number of samples stored on each processor

Definition at line 78 of file DistributedCollection.cpp.

References comm, LocalSize(), and size().

Referenced by AsGlobalMatrix(), GlobalAt(), GlobalWeights(), and size().

◆ GlobalVariance()

Eigen::VectorXd DistributedCollection::GlobalVariance ( int  blockDim = -1) const

Compute the variance using all of the samples.

Parameters
[in]blockDimCompute the variance of this block
Returns
The global variance

Definition at line 106 of file DistributedCollection.cpp.

References GlobalEigenMean(), and LocalVariance().

Referenced by Variance().

◆ GlobalWeights()

Eigen::VectorXd DistributedCollection::GlobalWeights ( ) const

Return all of the weights as a vector.

Parameters
[in]blockDimReturn the weights of this block
Returns
The weights

Definition at line 162 of file DistributedCollection.cpp.

References comm, GlobalSize(), LocalSize(), and LocalWeights().

Referenced by Weights().

◆ LocalAt() [1/2]

std::shared_ptr< SamplingState > DistributedCollection::LocalAt ( unsigned  i)

Get the local state at the \(i^{th}\) index.

Parameters
[in]iThe local index

Definition at line 22 of file DistributedCollection.cpp.

References collection, and size().

Referenced by GlobalAt().

◆ LocalAt() [2/2]

const std::shared_ptr< SamplingState > DistributedCollection::LocalAt ( unsigned  i) const

Get the local state at the \(i^{th}\) index.

Parameters
[in]iThe local index

Definition at line 27 of file DistributedCollection.cpp.

References collection, and size().

◆ LocalCentralMoment()

Eigen::VectorXd DistributedCollection::LocalCentralMoment ( unsigned  order,
int  blockDim = -1 
) const

Computes the componentwise central moments (e.g., variance, skewness, kurtosis, etc..) of a specific order.

Parameters
[in]orderThe order of the central moment
[in]blockDimCompute the central moment of this block
Returns
The central moment using only local samples

Definition at line 92 of file DistributedCollection.cpp.

References collection, and GlobalMean().

Referenced by GlobalCentralMoment().

◆ LocalCovariance()

Eigen::MatrixXd DistributedCollection::LocalCovariance ( int  blockDim = -1) const

Compute the covariance using only local samples.

Parameters
[in]blockDimCompute the covariance of this block
Returns
The local covariance

Definition at line 110 of file DistributedCollection.cpp.

References collection, and GlobalMean().

Referenced by GlobalCovariance().

◆ LocalESS()

Eigen::VectorXd DistributedCollection::LocalESS ( int  blockDim = -1) const

Compute the ESS using only local samples.

Parameters
[in]blockDimCompute the ESS of this block
Returns
The local ESS

Definition at line 116 of file DistributedCollection.cpp.

References collection.

Referenced by GlobalESS().

◆ LocalExpectedValue()

Eigen::VectorXd DistributedCollection::LocalExpectedValue ( std::shared_ptr< muq::Modeling::ModPiece > const &  f,
std::vector< std::string > const &  metains = std::vector<std::string>() 
) const

Definition at line 207 of file DistributedCollection.cpp.

References collection.

Referenced by GlobalExpectedValue().

◆ LocalMean()

Eigen::VectorXd DistributedCollection::LocalMean ( int  blockDim = -1) const

Compute the mean using only local samples.

Parameters
[in]blockDimCompute the mean of this block
Returns
The local mean

Definition at line 98 of file DistributedCollection.cpp.

References collection.

Referenced by GlobalMean().

◆ LocalSize()

unsigned int DistributedCollection::LocalSize ( ) const

The number of samples stored locally.

Returns
The number of samples stored on this processor

Definition at line 76 of file DistributedCollection.cpp.

References collection.

Referenced by AsGlobalMatrix(), GlobalAt(), GlobalSize(), and GlobalWeights().

◆ LocalVariance()

Eigen::VectorXd DistributedCollection::LocalVariance ( int  blockDim = -1) const

Compute the variance using only local samples.

Parameters
[in]blockDimCompute the variance of this block
Returns
The local variance

Definition at line 104 of file DistributedCollection.cpp.

References collection.

Referenced by GlobalVariance().

◆ LocalWeights()

Eigen::VectorXd DistributedCollection::LocalWeights ( ) const

Return all of the weights on this processor as a vector.

Parameters
[in]blockDimReturn the weights of this block
Returns
The weights

Definition at line 160 of file DistributedCollection.cpp.

References collection.

Referenced by GlobalWeights().

◆ Mean()

Eigen::VectorXd DistributedCollection::Mean ( int  blockDim = -1) const
overridevirtual

Compute the mean using all of the samples.

Defaults to the global mean

Parameters
[in]blockDimCompute the mean of this block
Returns
The global mean

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 102 of file DistributedCollection.cpp.

References GlobalMean().

◆ size()

unsigned int DistributedCollection::size ( ) const
overridevirtual

The total number of samples.

By default the size returns the global size.

Returns
The sum of the number of samples stored on each processor

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 90 of file DistributedCollection.cpp.

References GlobalSize().

Referenced by GlobalAt(), GlobalSize(), and LocalAt().

◆ Variance()

Eigen::VectorXd DistributedCollection::Variance ( int  blockDim = -1) const
overridevirtual

Compute the variance using all of the samples.

Defaults to using the global variance.

Parameters
[in]blockDimCompute the variance of this block
Returns
The global variance

Reimplemented from muq::SamplingAlgorithms::SampleEstimator.

Definition at line 108 of file DistributedCollection.cpp.

References GlobalVariance().

◆ Weights()

Eigen::VectorXd DistributedCollection::Weights ( ) const
overridevirtual

Return all of the weights as a vector.

Parameters
[in]blockDimReturn the weights of this block
Returns
The weights

Reimplemented from muq::SamplingAlgorithms::SampleCollection.

Definition at line 183 of file DistributedCollection.cpp.

References GlobalWeights().

◆ WriteToFile()

void DistributedCollection::WriteToFile ( std::string const &  filename,
std::string const &  dataset = "/" 
) const
overridevirtual

Writes the local samples to file

Parameters
[in]filenameThe name of the file
[in]datasetThe name of the group within the file

Definition at line 187 of file DistributedCollection.cpp.

References collection.

Member Data Documentation

◆ collection

std::shared_ptr<SampleCollection> muq::SamplingAlgorithms::DistributedCollection::collection
private

The local sample collection (stored on this processor)

Definition at line 274 of file DistributedCollection.h.

Referenced by Add(), AsLocalMatrix(), LocalAt(), LocalCentralMoment(), LocalCovariance(), LocalESS(), LocalExpectedValue(), LocalMean(), LocalSize(), LocalVariance(), LocalWeights(), and WriteToFile().

◆ comm

std::shared_ptr<parcer::Communicator> muq::SamplingAlgorithms::DistributedCollection::comm
private

The communicator for this collection.

Definition at line 277 of file DistributedCollection.h.

Referenced by AsGlobalMatrix(), GlobalAt(), GlobalEigenMean(), GlobalESS(), GlobalExpectedValue(), GlobalSize(), and GlobalWeights().


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