This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

version number: 0.0.1
author: Will McGinnis


A simple framework for analyzing decision processes as directed graphs.

Simulating uncertain decisions

Inspired by the [St. Petersburg paradox](,
where the expected value of a simple game is infinity, unless reasonable contraints are set (i.e. the bank doesn't have
and infinite bankroll, you don't have infinite time to play, etc.). The idea is that we can represent decisions and the
decisions they lead to as directed acyclic graphs, wherein the nodes have payoffs, edges have costs, and at each node,
the edge to progress on to is selected at random (with weights).

With such a graph assembled, we can simulate the different first choices to see what the expected (simulated) outcome of
each is.

Future goals

In the future the plan is to add things like extremely rare and extreme events at each node (i.e. unknown unknowns, or
black swans), more complex switching logic at nodes than weighted random, more complex cost and payoff models (utility),
and better methods for building complex graphs.

The first outcome will be more detailed metrics on the simulated outcomes than just mean (simulated expected value). Of
course a positive expected value with extremely high risk is different than the same expected value without. We'd love
to capture that concisely.

Installation / Usage

To install use pip:

$ pip install petersburg

Or clone the repo:

$ git clone
$ python install




Here is a simple example of simulating the St. Petersburg Paradox game, with some slight variations. In this case the
entrance fee is $10, and the game only has a maximum of 10,000 flips and is played 10,000,000 times.

from petersburg import Graph

if __name__ == '__main__':
g = Graph()

# st petersburg paradox w/ $10 entrance fee and only 10000 possible flips
entrance_fee = 10
gd = {1: {'payoff': 0, 'after': []}, 2: {'payoff': 0, 'after': [{'node_id': 1, 'cost': entrance_fee}]}}
nn = 3
for idx in range(10000):
node_id = 2 * (idx + 1)
payoff = 2 ** (idx + 1)
gd[nn] = {'payoff': payoff, 'after': [{'node_id': node_id, 'cost': 0, 'weight': 1}]}
nn += 1
gd[nn] = {'payoff': 0, 'after': [{'node_id': node_id, 'cost': 0, 'weight': 1}]}
nn += 1

outcomes = []
for _ in range(10000000):

print('\n\nSimulated Output')

Via simulation, the outcome of this is a profit of: $197,592,288. This will, of course, vary depending on the run, but
will approach infinity as the number of games goes to infinity, regardless of cost-to-play.
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
petersburg-0.0.1.tar.gz (6.5 kB) Copy SHA256 Checksum SHA256 Source Jan 16, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting