1 #include "AllClassWrappers.h"
14 #include <pybind11/pybind11.h>
15 #include <pybind11/stl.h>
16 #include <pybind11/eigen.h>
30 py::class_<SamplingStateIdentity, std::shared_ptr<SamplingStateIdentity>> ssID(m,
"SamplingStateIdentity");
42 py::class_<SampleEstimator, std::shared_ptr<SampleEstimator>>(m,
"SampleEstimator")
52 .def(
"StandardizedMoment", (Eigen::VectorXd (
SampleEstimator::*)(
unsigned int, Eigen::VectorXd
const&, Eigen::VectorXd
const&,
int)
const) &
SampleEstimator::StandardizedMoment, py::arg(
"order"), py::arg(
"mean"),py::arg(
"stdDev"), py::arg(
"blockDim") = -1)
55 .def(
"Skewness", (Eigen::VectorXd (
SampleEstimator::*)(Eigen::VectorXd
const&, Eigen::VectorXd
const&,
int)
const) &
SampleEstimator::Skewness, py::arg(
"mean"),py::arg(
"stdDev"), py::arg(
"blockDim") = -1)
58 .def(
"Kurtosis", (Eigen::VectorXd (
SampleEstimator::*)(Eigen::VectorXd
const&, Eigen::VectorXd
const&,
int)
const) &
SampleEstimator::Kurtosis, py::arg(
"mean"),py::arg(
"stdDev"), py::arg(
"blockDim") = -1)
64 py::class_<MultiIndexEstimator, SampleEstimator, std::shared_ptr<MultiIndexEstimator>>(m,
"MultiIndexEstimator")
65 .def(py::init<std::vector<std::shared_ptr<MIMCMCBox>>>());
67 py::class_<SampleCollection, SampleEstimator, std::shared_ptr<SampleCollection>> sampColl(m,
"SampleCollection");
80 .def(
"ListMeta", &SampleCollection::ListMeta, py::arg(
"requireAll")=
true)
81 .def(
"WriteToFile", (
void (
SampleCollection::*)(std::string
const&, std::string
const&)
const) &SampleCollection::WriteToFile, py::arg(
"filename"), py::arg(
"dataset") =
"/")
90 py::class_<MarkovChain, SampleCollection, SampleEstimator, std::shared_ptr<MarkovChain>>(m,
"MarkovChain")
96 m.def_submodule(
"Diagnostics")
97 .def(
"Rhat", [](std::vector<std::shared_ptr<SampleCollection>>
const& collections){
return Diagnostics::Rhat(collections);})
98 .def(
"Rhat", [](std::vector<std::shared_ptr<SampleCollection>>
const& collections, py::dict opts){
return Diagnostics::Rhat(collections,
ConvertDictToPtree(opts));})
99 .def(
"Rhat", [](std::vector<std::shared_ptr<MarkovChain>>
const& collections){
return Diagnostics::Rhat(collections);})
100 .def(
"Rhat", [](std::vector<std::shared_ptr<MarkovChain>>
const& collections, py::dict opts){
return Diagnostics::Rhat(collections,
ConvertDictToPtree(opts));})
101 .def(
"Rhat", [](std::vector<std::shared_ptr<MultiIndexEstimator>>
const& collections){
return Diagnostics::Rhat(collections);})
102 .def(
"Rhat", [](std::vector<std::shared_ptr<MultiIndexEstimator>>
const& collections, py::dict opts){
return Diagnostics::Rhat(collections,
ConvertDictToPtree(opts));})
103 .def(
"BasicRhat", &Diagnostics::BasicRhat)
104 .def(
"BasicMPSRF", &Diagnostics::BasicMPSRF)
105 .def(
"SplitChains", [](std::vector<std::shared_ptr<SampleCollection>>
const& origChains,
unsigned int numSegments){
return Diagnostics::SplitChains(origChains,numSegments);})
106 .def(
"TransformChains", &Diagnostics::TransformChains)
107 .def(
"ComputeRanks", &Diagnostics::ComputeRanks);
110 py::class_<SamplingState, std::shared_ptr<SamplingState>> sampState(m,
"SamplingState");
112 .def(py::init<Eigen::VectorXd const&>())
113 .def(py::init<Eigen::VectorXd const&, double>())
114 .def(py::init<std::vector<Eigen::VectorXd>
const&>())
115 .def(py::init<std::vector<Eigen::VectorXd>
const&,
double>())
119 .def(
"GetMeta", [](std::shared_ptr<SamplingState>
self, std::string
const& metaKey)
121 return self->meta.at(metaKey);
123 .def(
"GetMetaSamplingState", [](std::shared_ptr<SamplingState>
self, std::string
const& metaKey)
124 -> std::shared_ptr<SamplingState> {
Eigen::VectorXd WolffError(int blockDim) const
static double SingleComponentWolffESS(Eigen::Ref< const Eigen::VectorXd > const &trace)
Eigen::VectorXd WolffESS(int blockDim) const
A class to hold and analyze a collection of SamplingState objects.
virtual std::shared_ptr< SamplingState > at(unsigned i)
std::unordered_map< std::string, Eigen::MatrixXd > GetMeta() const
double MultiBatchESS(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 std::vector< Eigen::MatrixXd > RunningCovariance(int blockInd=-1) const
virtual std::shared_ptr< SampleCollection > tail(unsigned int N) const
virtual std::shared_ptr< SampleCollection > segment(unsigned int startInd, unsigned int length, unsigned int skipBy=1) const
virtual void Add(std::shared_ptr< SamplingState > newSamp)
virtual Eigen::MatrixXd AsMatrix(int blockDim=-1) const
virtual std::shared_ptr< SampleCollection > head(unsigned int N) const
Eigen::VectorXd BatchESS(int blockInd=-1, int batchSize=-1, int overlap=-1) const
virtual Eigen::VectorXd Weights() const
static std::shared_ptr< SampleCollection > FromMatrix(Eigen::MatrixXd const &samps)
virtual unsigned int size() const
virtual Eigen::VectorXd BatchError(int blockInd=-1, int batchSize=-1, int overlap=-1) const
Abstract base class for computing sample-based approximations of expectations.
virtual Eigen::MatrixXd Covariance(int blockInd=-1) const
virtual Eigen::VectorXd Skewness(int blockInd=-1) const
virtual Eigen::VectorXd ExpectedValue(std::shared_ptr< muq::Modeling::ModPiece > const &f, std::vector< std::string > const &metains=std::vector< std::string >()) const =0
virtual Eigen::VectorXd StandardError(int blockInd, std::string const &method) const =0
virtual Eigen::VectorXd CentralMoment(unsigned int order, int blockNum=-1) const
virtual Eigen::VectorXd StandardizedMoment(unsigned int order, int blockInd=-1) const
virtual Eigen::VectorXd Mean(int blockInd=-1) const
virtual Eigen::VectorXd Kurtosis(int blockInd=-1) const
virtual Eigen::VectorXd Variance(int blockInd=-1) const
virtual Eigen::VectorXd ESS(int blockInd, std::string const &method) const =0
int TotalDim() const
The total number of parameters in the state, i.e., the sum of state[i].size()
double weight
The weight of this state.
std::vector< Eigen::VectorXd > state
The state variables.
bool HasMeta(std::string const &metaKey)
Checks to see if the meta map contains a particular key.
Eigen::VectorXd ToVector(int blockInd=-1) const
Class for easily casting boost::any's in assignment operations.
void SampleWrapper(pybind11::module &m)
boost::property_tree::ptree ConvertDictToPtree(pybind11::dict dict)