## lppl

`lppl`

*(Disclaimer – this page is written for geeks like me. A more publicly accessible explanation of the lppl vision is coming soon.)*

Open-universe probabilistic programming in modern C++, done in exactly the idiosyncratic way that I want to do it.

- Record-based (which essentially means trace-based, but we don’t hide the tracing from you)
- Sample-based, with posterior queries by default computed online rather than after sampling is complete – defaulting to constant memory complexity
- Explicit PRNG state (reproducibility)
- Algebraic sum types everywhere instead of boxing

This should look familiar.

```
template<size_t N>
std::tuple<double, double>
linear_regression(record_t<Normal, Gamma>& r, std::shared_ptr<data_1d<N>> data) {
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);
}
```

`lppl`

is open-source and available at this webpage.
There’s lots of documentation! You can also download the latest tagged version of the source, or see all versions.

⚠️ Versions of

`lppl`

greater than v0.9.0 have changed licenses from LGPL3 to GPL3. Please contact us if you are interested in a license exception.

## Details

### Associated tools

`glppl`

transforms`lppl`

programs into probability distributions over directed graphical models.

### Inference

`lppl`

supports the following inference algorithms:

- importance sampling
- likelihood weighting
- generic importance sampling with user-defined proposal

- metropolis-hastings
- ancestor metropolis
- generic metropolis with user-defined proposal

- generic filtering using any inference algorithm to compute updates

More algorithms to come…

### Coming attractions

- optionally zero dynamic allocation (yes, even in open-universe models)
- other inference algorithms (CSIS, ADVI, …)
- some inference algorithms may end up going in separate libraries, since they might depend on external libraries (e.g., Adept for neural network-based inference). This is all very hypothetical anyway.

- more query types, and composability of queries

The `lppl`

webpage and its subpages are licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.