Probabilistic programming languages (PPLs) allow programmers to construct statistical models and then simulate data or perform inference over them. Many PPLs restrict models to a particular instance of simulation or inference, limiting their reusability. In other PPLs, models are not readily composable. Using Haskell as the host language, we present an embedded domain specific language based on algebraic effects, where probabilistic models are modular, first-class, and reusable for both simulation and inference. We also demonstrate how simulation and inference can be expressed naturally as composable program transformations using algebraic effect handlers.
翻译:概率编程语言(PPLs)允许程序设计员建立统计模型,然后模拟数据或对其进行推断。许多 PPL 将模型限制在特定的模拟或推断实例中,限制其可再使用性。在其他 PPL 中,模型不易合成。用Haskell作为主机语言,我们展示了一种基于代数效应的嵌入域特定语言,其中概率模型是模块、一等和可同时用于模拟和推断的。我们还演示了如何用代数效果处理器将模拟和推断自然地表述为可作复制程序转换。