Added documentation to the python file. It was mostly copied from the Matlab version, so there may be a bug or two in it.