Memory-efficient open-universe probabilistic programming in modern C++. Deep dive here. Program synthesis here.
This should look familiar.
template<size_t N>
std::tuple<double, double>
record_t<DTypes<Normal, Gamma>>& r, std::shared_ptr<data_1d<N>> data) {
linear_regression(auto intercept = sample(r, "intercept", Normal(), rng);
auto slope = sample(r, "slope", Normal(), rng);
auto scale = sample(r, "scale", Gamma(), rng);
for (size_t ix = 0; ix != N; ix++) {
observe(
r,"obs/" + std::to_string(ix),
Normal(data->x[ix] * slope + intercept, scale),
data->y[ix]
);
}return std::make_tuple(intercept, slope);
}
The lppl
webpage and its subpages are licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.