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

The PDist is designed to make it easy to make it easy to make things happen in a probablistic manner. Provide keys with an associated probability attached, and then call the resulting object when you need a new value.

>>> mood = PDist({'happy': 0.3, 'neutral': 0.6, 'sad': 0.1})
>>> mood()
>>> mood()

You can retrieve the distribution of how those values are applied by accessing the PDist.distribution attribute:

>>> mood.distribution
[('happy', 0.3), ('neutral', 0.6), ('sad', 0.1)]

As well as providing a dict to assign probabilities, you can send in a list of lists/tuples. This allows for for non-hashable types to be used. This means that you provide objects such as functions to be used as keys:

>>> def grumpy(news):
...    return ':/'
>>> def happy(news):
...    return ':)'
>>> react = PDist([(grumpy, 0.7), (happy, 0.3)])
>>> reaction = react()
>>> reaction("We're getting married!")

You are not restricted to adding your input variables up to 1. For example, if you only have a tally chart, and wish to calculate a probability distribution from that sample, you can provide that too:

>>> spotted = {'geese': 0, 'ducks': 12, 'sparrows': 4, 'other': 39}
>>> bird_pdist = PDist(spotted)
>>> bird_pdist.distribution
[('geese', 0.0), ('sparrows', 0.07272727272727272), ('ducks', 0.21818181818181817), ('other', 0.7090909090909091)]

Retrieving the probability of a particular key is supported. However, the search strategy is very inefficient and probably shouldn’t be used outside of the interactive Python shell.

>>> bird_pdist['geese']
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
choices-0.1.tar.gz (2.5 kB) Copy SHA256 Checksum SHA256 Source Feb 25, 2012

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