Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A library for computing expectation values

Project description

## What?

Implements the standard math syntax for expectation values of random variables on finite sets

## How?

This is best explained with an example:

# import the objects
from random_variable import RandomVariable, E

# define a universe for example the possible outcomes of a dice
dice = [1, 2, 3, 4, 5, 6]

# define one random variable
X = RandomVariable(dice)

# compute and print expectation values
print('mean:', E[X])
print('one minus mean:', E[1-X])
print('twice the mean:', E[X*2])
print('variance:', E[(X-E[X])**2])
print('variance again:', E[X**2]-E[X]**2)
print('standard deviation:', (E[X**2]-E[X]**2)**0.5)
print('skewness:', E[(X-E[X])**3]/E[(X-E[X])**2]**1.5)
print('kurtosis:', E[(X-E[X])**4]/E[(X-E[X])**2]**2)
print('some other complex expectation value:', E[sin(2*X)*cos(X+1)])

(works in both python 2 and python 3)

## License

BSD v3 - Created by Prof. Massimo Di Pierro (DePaul Universty) 2018

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for random-variable, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size random_variable-0.2.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page