Class for estimating expectations using multi-index samples from MC or MCMC. More...
#include <MultiIndexEstimator.h>
Class for estimating expectations using multi-index samples from MC or MCMC.
Definition at line 15 of file MultiIndexEstimator.h.
Public Member Functions | |
MultiIndexEstimator (std::vector< std::shared_ptr< MIMCMCBox >> const &boxesIn, bool useQoisIn=false) | |
virtual | ~MultiIndexEstimator ()=default |
virtual unsigned int | BlockSize (int blockInd) const override |
virtual unsigned int | NumBlocks () const override |
virtual Eigen::VectorXd | ExpectedValue (std::shared_ptr< muq::Modeling::ModPiece > const &f, std::vector< std::string > const &metains=std::vector< std::string >()) const override |
virtual Eigen::MatrixXd | Covariance (int blockInd=-1) const override |
virtual Eigen::MatrixXd | Covariance (Eigen::VectorXd const &mean, int blockInd=-1) const override |
virtual Eigen::VectorXd | StandardError (int blockDim, std::string const &method) const override |
virtual Eigen::VectorXd | StandardError (std::string const &method="Batch") const override |
virtual Eigen::VectorXd | StandardError (int blockDim) const override |
virtual Eigen::VectorXd | ESS (std::string const &method="Batch") const override |
virtual Eigen::VectorXd | ESS (int blockDim) const override |
virtual Eigen::VectorXd | ESS (int blockDim, std::string const &method) const override |
Public Member Functions inherited from muq::SamplingAlgorithms::SampleEstimator | |
virtual | ~SampleEstimator ()=default |
virtual Eigen::VectorXd | CentralMoment (unsigned int order, int blockNum=-1) const |
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 | Mean (int blockInd=-1) const |
virtual Eigen::VectorXd | Variance (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 |
MultiIndexEstimator::MultiIndexEstimator | ( | std::vector< std::shared_ptr< MIMCMCBox >> const & | boxesIn, |
bool | useQoisIn = false |
||
) |
Construct the multiindex estimator using MIMCMC boxes. These boxes are typically constructed by a MIMCMC methods such as the GreedyMLMCMC or MIMCMC classes.
[in] | boxesIn | "Boxes" holding the differences between chains at different indices |
[in] | useQoisIn | (optional) Whether this estimator should use the QOIs in the chains or the parameters themselves. Defaults to false, which implies the parameters will be used in the estimates. |
Definition at line 7 of file MultiIndexEstimator.cpp.
|
virtualdefault |
|
overridevirtual |
Returns the size \(N_i\) of each block. If blockInd==-1
, the size \(N\) of the joint random variable is returned.
Implements muq::SamplingAlgorithms::SampleEstimator.
Definition at line 15 of file MultiIndexEstimator.cpp.
References blockSizes.
Referenced by Covariance().
|
overridevirtual |
Computes the sample covariance using a precomputed (or known) mean.
If blockInd is non-negative, only the mean of one block of the samples is computed.
Implements muq::SamplingAlgorithms::SampleEstimator.
Definition at line 157 of file MultiIndexEstimator.cpp.
References BlockSize(), boxes, and useQois.
|
inlineoverridevirtual |
Computes the sample covariance of \(x\) with itself (if blockInd==-1
) or \(x_i\) with itself (if blockInd==i
), i.e.,
\[ \text{Cov}[x] = \mathbb{E}\left[ \left(x-\mathbb{E}[x]\right)\left(x-\mathbb{E}[x]\right)^T\right] \]
or
\[ \text{Cov}[x_i] = \mathbb{E}\left[ \left(x_i-\mathbb{E}[x_i]\right)\left(x_i-\mathbb{E}[x_i]\right)^T\right] \]
Note that it is only possible to compute the cross covariance of \(x_i\) with \(x_j\) by setting blockInd=-1
and computing the entire covariance matrix.
[in] | blockInd | (Optional) The block of the random variable $x$ to use in the expectation. By default, blockInd=-1 and the expectation is computed with respect to the entire random variable $x$. |
Reimplemented from muq::SamplingAlgorithms::SampleEstimator.
Definition at line 39 of file MultiIndexEstimator.h.
References muq::SamplingAlgorithms::SampleEstimator::Covariance().
|
inlineoverridevirtual |
Reimplemented from muq::SamplingAlgorithms::SampleEstimator.
Definition at line 69 of file MultiIndexEstimator.h.
References ESS().
Referenced by ESS().
|
overridevirtual |
Returns an estimate of the effective sample size (ESS), which is the number of independent samples of the target distribution that would be needed to obtain the same statistical accuracy as this estimator. For independent samples, the estimator variance (squared MCSE) \(\hat{\sigma}^2\f=\sigma^2/ N\). Given the estimator variance \(\hat{\sigma}^2\), the effective sample size is then given by the ratio of the target distribution variance and the estimator variance:
\[ \text{ESS} = \frac{\sigma^2}{\hat{\sigma}^2}. \]
[in] | blockInd | Specifies the block of the sampling state we're interested in. Defaults to -1, which will result in all blocks of the sampling state being concatenated in the MCSE estimate. |
[in] | method | A string describing what method should be used to estimate the MCSE. Defaults to "Batch". Other options include "MultiBatch" or "Wolff". For details, see the SampleCollection class. |
Implements muq::SamplingAlgorithms::SampleEstimator.
Definition at line 43 of file MultiIndexEstimator.cpp.
References StandardError(), and muq::SamplingAlgorithms::SampleEstimator::Variance().
|
inlineoverridevirtual |
This function returns an estimate of the Effective Sample Size (ESS) of this estimator. The ESS here refers to the number of indepedent samples that would be required in a classic single-level Monte Carlo estimate to achieve the same statistical accuracy as this multi-index estimator.
This function computes the ESS by computing the ratio of the sample variance with the squared MCSE. The MCSE is computed by the MultiIndex::StandardError function.
[in] | method | Specifies the type of MCSE estimator used by the single level chains to estimate the variance of each term in the multiindex telescoping series. See MarkovChain::ESS for more details. |
method=="MultiBatch"
, this function returns length 1 vector containing a single multivariate effective sample size estimate. If method!="MultiBatch"
, this function returns an ESS for each component of the chain. Reimplemented from muq::SamplingAlgorithms::SampleEstimator.
Definition at line 68 of file MultiIndexEstimator.h.
References ESS().
Referenced by ESS().
|
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 115 of file MultiIndexEstimator.cpp.
|
private |
Creates a Markov chain for each term in the telescoping sum.
[in] | blockInd | (optional) The index of the block we're interested in. If -1, then all blocks in the state are concatenated. This is not used if the f argument is specified. |
[in] | f | (optional), A ModPiece that evaluates a quantity of interest if we're interested in chains over the QOI difference. |
Definition at line 50 of file MultiIndexEstimator.cpp.
References boxes, diffChains, and useQois.
Referenced by StandardError().
|
overridevirtual |
Returns the nubmer of block \(M\).
Implements muq::SamplingAlgorithms::SampleEstimator.
Definition at line 25 of file MultiIndexEstimator.cpp.
References blockSizes.
|
inlineoverridevirtual |
Reimplemented from muq::SamplingAlgorithms::SampleEstimator.
Definition at line 56 of file MultiIndexEstimator.h.
References StandardError().
Referenced by StandardError().
|
overridevirtual |
Computes the standard deviation mean value returned by theis MultiIndexEstimator. The estimator variances for each term in the telescoping series are summed and the square root of this quantity is returned. This process assumes that the terms in the series are independent. The value of Method is passed on to the underlying SampleCollection classes to compute the variance of each term. Valid options are Batch
, MultiBatch
, and Wolff
.
[in] | blockDim | Specifies the block that we wish to use in the MCSE estimator. Defaults to -1, which results in all blocks of the chain being concatenated in the MCSE estimate. |
[in] | method | Specifies the type of MCSE estimator used by the single level chains to estimate the variance of each term in the multiindex telescoping series. See MarkovChain::StandardError for more details. |
method=="MultiBatch"
, this function returns length 1 vector containing a single multivariate MCSE estimate. If method!="MultiBatch"
, this function returns the MCSE for each component of the chain. Implements muq::SamplingAlgorithms::SampleEstimator.
Definition at line 30 of file MultiIndexEstimator.cpp.
References GetDiffChains().
Referenced by ESS().
|
inlineoverridevirtual |
Reimplemented from muq::SamplingAlgorithms::SampleEstimator.
Definition at line 55 of file MultiIndexEstimator.h.
References StandardError().
Referenced by StandardError().
|
private |
Definition at line 84 of file MultiIndexEstimator.h.
Referenced by BlockSize(), and NumBlocks().
|
private |
Definition at line 87 of file MultiIndexEstimator.h.
Referenced by Covariance(), ExpectedValue(), and GetDiffChains().
|
private |
Definition at line 88 of file MultiIndexEstimator.h.
Referenced by GetDiffChains().
|
private |
Definition at line 85 of file MultiIndexEstimator.h.
Referenced by Covariance(), ExpectedValue(), and GetDiffChains().