14 template<
typename MeanType,
typename KernelType>
15 std::shared_ptr<GaussianProcess>
BuildGP(MeanType
const& mu, KernelType
const& kernel)
17 return std::make_shared<GaussianProcess>(mu.Clone(), kernel.Clone());
20 template<
typename MeanType,
typename KernelType>
21 std::shared_ptr<GaussianProcess>
BuildStateSpaceGP(MeanType
const& mu, KernelType
const& kernel)
23 boost::property_tree::ptree options;
24 options.put(
"SDE.dt", 1
e-2);
26 return std::make_shared<StateSpaceGP>(mu.Clone(), kernel.Clone(), options);
32 string dataFile =
"data/MaunaLoaCO2.h5";
35 Eigen::VectorXd times = f[
"/Weekly/Dates"];
36 Eigen::VectorXd concentrations = f[
"/Weekly/Concentrations" ];
40 double k1_length = 60;
41 double k1_nu = 5.0/2.0;
46 double k2_period = 1.0;
47 double k2_length = 0.5;
48 auto k2 = PeriodicKernel(1, k2_var, k2_length, k2_period);
52 double k3_length = 30;
53 double k3_nu = 3.0/2.0;
58 double k4_length = 2.0;
59 double k4_nu = 3.0/2.0;
63 auto k = k1 + k2*k3 + k4;
76 Eigen::MatrixXd evalPts(1, numPts);
77 evalPts.row(0) = Eigen::VectorXd::LinSpaced(numPts, 2010, 2020);
79 gp->Condition(times.transpose(), concentrations.transpose(), 16);
80 Eigen::MatrixXd postMean, postVar;
81 std::tie(postMean,postVar) = gp->Predict(evalPts, GaussianProcess::DiagonalCov);
84 string writeFile =
"results/CO2_Prediction.h5";
87 fout[
"/Predict/Dates"] = evalPts;
88 fout[
"/Predict/Concentrations"] = postMean;
89 fout[
"/Predict/ConcentrationVariance"] = postVar;
std::shared_ptr< GaussianProcess > BuildGP(MeanType const &mu, KernelType const &kernel)
std::shared_ptr< GaussianProcess > BuildStateSpaceGP(MeanType const &mu, KernelType const &kernel)
H5Object OpenFile(std::string const &filename)
Open an HDF5 file and return the root object.