Multivariate Normal CDF in Python using scipy

前端 未结 3 843
不思量自难忘°
不思量自难忘° 2020-12-06 01:36

In order to calculate the CDF of a multivariate normal, I followed this example (for the univariate case) but cannot interpret the output produced by scipy:

         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-06 02:07

    After searching a lot, I think this blog entry by Noah H. Silbert describes the only readymade code from a standard library that can be used for computing the cdf for a multivariate normal in Python. Scipy has a way to do it but as mentioned in the blog, it is difficult to find. The approach is based on a paper by Alan Genz’s.

    From the blog, this is how it works.

    from scipy.stats import mvn
    import numpy as np
    low = np.array([-10, -10])
    upp = np.array([.1, -.2])
    mu = np.array([-.3, .17])
    S = np.array([[1.2,.35],[.35,2.1]])
    p,i = mvn.mvnun(low,upp,mu,S)
    print p
    
    0.2881578675080012
    

提交回复
热议问题