I had to write an option model that was using a bivariate distribution in Python. However, I did not find a prebuilt function that was fast - some seem to be using the random scipy generator to emulate it with the multivariate function. BUT... if you really dig deep and see what the other financial packages are using, it's pretty much ALL code written by one guy, Alan Genz from the University of Washington. He pretty much writes everything in Fortan or MATLAB, and that's it. So if you look into packages that have the bivariate CDF you'll find his name and his code there (I found an old version in MATLAB actually). http://www.math.wsu.edu/faculty/genz/software/software.html So why this isn't built into SciPy or NumPy already, I have no idea. But I rewrote it in several hours, using both MATLAB and Python to check the resulting code. He's solving with Gauss Legendre quadrature so this will always be much faster than a solution that uses a random number generator: https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_quadrature |