Python_Option_Pricing icon indicating copy to clipboard operation
Python_Option_Pricing copied to clipboard

The function "mvndst" doesn't exist anymore in scipy.stats.

Open marcovth opened this issue 8 months ago • 4 comments

Hello ...

Unfortunately, the function "mvndst" doesn't exist anymore in scipy.stats. It seems, scipy relied on a Fortran module, and they had to remove it.

Do you think you could help me to find a replacement?

Thanks a lot.

# Cumulative Bivariate Normal Distribution
# Primarily called by Psi() function, part of the _Bjerksund_Stensland_2002 model
def _cbnd(a, b, rho):
    # This distribution uses the Genz multi-variate normal distribution 
    # code found as part of the standard SciPy distribution
    lower = np.array([0, 0])
    upper = np.array([a, b])
    infin = np.array([0, 0])
    correl = rho
    error, value, inform = mvn.mvndst(lower, upper, infin, correl)
    return value

marcovth avatar May 12 '25 16:05 marcovth

I will start looking into a replacement. Davis EdwardsOn May 12, 2025, at 12:16 PM, marcovth @.***> wrote: marcovth created an issue (dedwards25/Python_Option_Pricing#7) Hello ... Unfortunately, the function "mvndst" doesn't exist anymore in scipy.stats. It seems, scipy relied on a Fortran module, and they had to remove it. Do you think you could help me to find a replacement? Thanks a lot.

Cumulative Bivariate Normal Distribution

Primarily called by Psi() function, part of the _Bjerksund_Stensland_2002 model

def _cbnd(a, b, rho): # This distribution uses the Genz multi-variate normal distribution # code found as part of the standard SciPy distribution lower = np.array([0, 0]) upper = np.array([a, b]) infin = np.array([0, 0]) correl = rho error, value, inform = mvn.mvndst(lower, upper, infin, correl) return value

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

dedwards25 avatar May 12 '25 16:05 dedwards25

I found the solution already ...

import scipy.stats

# Cumulative Bivariate Normal Distribution
def cbnd(a, b, rho):
    lower = np.array([0, 0])
    upper = np.array([a, b])
    infin = np.array([0, 0])
    correl = rho
    error, value, inform = scipy.stats._mvn.mvndst(lower, upper, infin, correl)
    return value

marcovth avatar May 12 '25 17:05 marcovth

I have created a python version of the FORTRAN function previously embedded in the mvn library. The new code is in the file name "2025".

dedwards25 avatar May 13 '25 18:05 dedwards25

Thank you very much. I will generate some curves tomorrow.

marcovth avatar May 13 '25 23:05 marcovth