9 Eigen::VectorXd SampleEstimator::CentralMoment(
unsigned int order,
12 return CentralMoment(order, Mean(blockNum), blockNum);
16 Eigen::VectorXd SampleEstimator::CentralMoment(
unsigned int order,
17 Eigen::VectorXd
const& mean,
23 Integrand(Eigen::VectorXd
const& meanIn,
26 Eigen::VectorXi
const& blockSizes) :
muq::Modeling::ModPiece(blockSizes, GetBlockSize(blockSizes,blockIndIn)*Eigen::VectorXi::Ones(1)),
27 localMean(meanIn), localOrder(orderIn), localBlockInd(blockIndIn){};
29 virtual ~Integrand() =
default;
35 outputs.at(0).resize(inputSizes.sum());
36 unsigned int cumSum = 0;
38 for(
unsigned int i=0; i<inputSizes.size(); ++i){
39 outputs.at(0).segment(cumSum,inputSizes(i)) = (inputs.at(i).get()-localMean.segment(cumSum,inputSizes(i))).array().pow(localOrder);
40 cumSum += inputSizes(i);
45 outputs.at(0) = (inputs.at(localBlockInd).get()-localMean).array().pow(localOrder);
49 static int GetBlockSize(Eigen::VectorXi
const& blockSizes,
int blockInd){
51 return blockSizes.sum();
53 return blockSizes(blockInd);
58 Eigen::VectorXd
const& localMean;
59 unsigned int localOrder;
65 Eigen::VectorXi blockSizes(NumBlocks());
66 for(
int i=0; i<NumBlocks(); ++i)
67 blockSizes(i) = BlockSize(i);
70 auto integrand = std::make_shared<Integrand>(mean, order, blockNum, blockSizes);
72 return ExpectedValue(integrand);
76 Eigen::VectorXd SampleEstimator::Mean(
int blockInd)
const
78 assert(BlockSize(blockInd)>0);
79 return CentralMoment(1, Eigen::VectorXd::Zero(BlockSize(blockInd)), blockInd);
82 Eigen::VectorXd SampleEstimator::Variance(
int blockInd)
const
84 return Variance(Mean(blockInd), blockInd);
87 Eigen::VectorXd SampleEstimator::Variance(Eigen::VectorXd
const& mean,
90 return CentralMoment(2, mean, blockInd);
93 Eigen::VectorXd SampleEstimator::StandardizedMoment(
unsigned int order,
int blockInd)
const
95 return StandardizedMoment(order, Mean(blockInd), blockInd);
98 Eigen::VectorXd SampleEstimator::StandardizedMoment(
unsigned int order,
99 Eigen::VectorXd
const& mean,
102 return StandardizedMoment(order, mean, Variance(mean,blockInd).array().sqrt(), blockInd);
105 Eigen::VectorXd SampleEstimator::StandardizedMoment(
unsigned int order,
106 Eigen::VectorXd
const& mean,
107 Eigen::VectorXd
const& stdDev,
110 Eigen::VectorXd moment = CentralMoment(order, mean, blockInd);
111 return moment.array() / stdDev.array().pow(order);
115 Eigen::VectorXd SampleEstimator::Skewness(
int blockInd)
const
117 return StandardizedMoment(3,blockInd);
120 Eigen::VectorXd SampleEstimator::Skewness(Eigen::VectorXd
const& mean,
123 return StandardizedMoment(3,mean, blockInd);
126 Eigen::VectorXd SampleEstimator::Skewness(Eigen::VectorXd
const& mean,
127 Eigen::VectorXd
const& stdDev,
130 return StandardizedMoment(3,mean, stdDev, blockInd);
133 Eigen::VectorXd SampleEstimator::Kurtosis(
int blockInd)
const
135 return StandardizedMoment(4,blockInd);
138 Eigen::VectorXd SampleEstimator::Kurtosis(Eigen::VectorXd
const& mean,
141 return StandardizedMoment(4,mean, blockInd);
144 Eigen::VectorXd SampleEstimator::Kurtosis(Eigen::VectorXd
const& mean,
145 Eigen::VectorXd
const& stdDev,
148 return StandardizedMoment(4,mean, stdDev, blockInd);
152 Eigen::MatrixXd SampleEstimator::Covariance(
int blockInd)
const
154 return Covariance(Mean(blockInd),blockInd);
Provides an abstract interface for defining vector-valued model components.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...