https://github.com/cran/GAS
Tip revision: 5b6062863bb2ac5de9bd14604256e6be00bdf36c authored by Leopoldo Catania on 19 August 2024, 09:00:52 UTC
version 0.3.4.1
version 0.3.4.1
Tip revision: 5b60628
Moments.cpp
#include <RcppArmadillo.h>
#include "DistWrap.h"
using namespace Rcpp;
using namespace arma;
//[[Rcpp::export]]
arma::mat EvalMoments_univ(arma::mat mTheta, std::string Dist){
int iT = mTheta.n_cols;
arma::mat mMoments(4,iT);
int t;
for(t=0;t<iT;t++){
mMoments.col(t) = mdist_univ(mTheta.col(t), Dist);
}
return mMoments.t();
}
//[[Rcpp::export]]
List EvalMoments_multi(arma::mat mTheta, std::string Dist, int iN){
int iT = mTheta.n_cols;
arma::mat mMu(iN,iT);
arma::cube mCov(iN,iN,iT);
int t;
for(t=0;t<iT;t++){
mMu.col(t) = mdist_multi_mean(mTheta.col(t), Dist, iN);
mCov.slice(t) = mdist_multi_cov(mTheta.col(t), Dist, iN);
}
List lMoments;
lMoments["mean"] = mMu.t();
lMoments["cov"] = mCov;
return lMoments;
}