Fitting probability distributions from binned / quantile data in Python

I’ve made an iPython Notebook that explains how to fit probability distributions to data when only binned values, or quantiles, or perhaps a cumulative distribution are available.  It uses a least squares fit approach.  View it by clicking the picture below:


The page includes a button to download the notebook so that you can play around with it yourself.

Python is a free and open source programming language that is becoming increasingly popular with scientists as a replacement for Matlab or IDL.  I hope that the notebook will be helpful to anyone who works with grainsize data e.g. volcanologists, sedimentologists, atmospheric scientists.

iPython notebooks are amazing; if you use Python for science and haven’t tried them yet, then I urge you to have a look.  They let you run Python code in little chunks, displaying the results immediately and interspersed with comments and LaTeX-rendered equations.  You can also render publicly-available notebooks using the iPython Notebook Viewer website, as I have done here.  I think that they are The Future.

iPython notebooks come nicely packaged for Windows and Mac in the Anaconda Python distribution (and probably others such as Enthought, too).  You can install the ipython-notebook package on Ubuntu-like Linux distributions with a single command (sudo apt-get install ipython-notebook), but to get the most up-to-date versions it is better to use pip:

# Depending on what is already installed, 
# you may also need to add some dependencies.
sudo apt-get install pandoc python-zmq python-tornado

# Install pip, then use pip to install ipython
sudo apt-get install python-pip
sudo pip install ipython
Categories: Uncategorized

Leave a comment:

Your email address will not be published. Required fields are marked *