|
|
|
|
|
by ppcsf
3530 days ago
|
|
I developed a PPL within C#, which I guess has a more familiar syntax for a lot of people. Basically, PPLs allow you to treat entire probabilistic models as primitives, and combine them as easily as we add integers. Let's say we have two models describing the distribution of university grades in America and India, and we want to combine them into a single model, where you have a 25% chance of being an American, and a 75% chance of being an Indian: var combined = from isAmerican in Bernoulli(0.25)
from grade in isAmerican ? americanGrades : indianGrades
select grade;
This is now a new model that can be composed further with other models. Building models like this feels very expressive.The inference method is also completely decoupled from the model specification process, allowing us to perform a Sequential Monte Carlo just by writing: var smcResults = combined.SmcMultiple(100);
or var pimhResults = combined.Pimh(10);
for a Particle-Independant Metropolis-Hastings.There's more examples here: https://github.com/joashc/csharp-probability-monad |
|