Skip to content

LFY/RandomT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RandomT: declarative probabilistic programming in Python
========================================================

Installation
============

python setup.py build
python setup.py install

Usage
=====

1. Import language environment

from RandomT import *

2. Construct random variable

X = RndVar(lambda : randint(0,1)) # Is some random integer

3. Combine with other random variables using base class methods

Y = X + X

4. Run probability queries

print Pr(Y, {}, rejectionN(500))

How to make a RandomT random variable
=====================================

2 ways.

1. Create a 0-arg function (thunk) that performs a draw from the distribution.
The function must return values of a consistent type, or the operations on this
random variable will not be well defined.

from random import randint

X = RndVar(lambda : randint(0, 5))

2. Create a Dist, which holds a dictionary describing the full probability
distribution. The keys must all be of the same type and must be hashable
objects, otherwise the operations on this random variable are not well
defined/sampled values cannot be meaningfully compared for equality.

X = RndVar(Dist({0 : 0.2, 1: 0.2, 2: 0.2, 3: 0.2, 4: 0.2}))

Currently supported inference algorithms
========================================

rejectionN(numsamples) - simple rejection sampling, works on any model

About

First-order probabilistic programming in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published