A Probabilistic Functional Programming Library for Haskell Version: June 2006 The PFP library is a collection of modules for Haskell that facilitates probabilistic functional programming, that is, programming with stochastic values. The probabilistic functional programming approach is based on a data type for representing distributions. A distribution represent the outcome of a probabilistic event as a collection of all possible values, tagged with their likelihood. Distributions can represent events, such as the roll of a die or the flip of a coin. For example, or example, the outcome of a die roll can be expressed as follows. die :: Dist Int die = uniform [1..6] The evaluation of die yields a distribution: > die 1 16.7% 2 16.7% 3 16.7% 4 16.7% 5 16.7% 6 16.7% The function uniform takes a list of elements and produces a distribution where each element is equally likely. We can also use functions like uniform to construct probabilistic functions, called transitions. Here is a transition which, given a number, either adds one or doesn't with equal probability. succOrId x = uniform [x, x+1] We could also represent this function using the choose operator which constructs a distribution of two elements. succOrId x = choose 0.5 x (x+1) Imagine we want to roll a dice, then either add one or not. We can use monadic operators to combine probabilistic operations. This can be represented concisely, or in a more verbose way. droll = die >>= succOrId Or: droll = do d <- die succOrId d The PFP library provides a set of function definitions that allow the declarative description and evaluation of probabilistic situations. These function can be employed in many different ways - be it solving of statistics problem from textbooks or the application to scientific problems. The approach is constructive by defining and applying probabilistic functions. To use the library: Download pfp-jun06.tar.gz Gunzip and untar the archive. This will create a directory pfp-jun06. Change to that dire...
First seen: 2025-09-03 18:57
Last seen: 2025-09-03 20:57