Multivariate Normal CDF in Python using scipy -


in order calculate cdf of multivariate normal, followed this example (for univariate case) cannot interpret output produced scipy:

from scipy.stats import norm import numpy np mean = np.array([1,5]) covariance = np.matrix([[1, 0.3 ],[0.3, 1]]) distribution = norm(loc=mean,scale = covariance) print distribution.cdf(np.array([2,4])) 

the output produced is:

[[  8.41344746e-01   4.29060333e-04]  [  9.99570940e-01   1.58655254e-01]] 

if joint cdf defined as:

p (x1 ≤ x1, . . . ,xn ≤ xn) 

then expected output should real number between 0 , 1.

after searching lot, think this blog entry noah h. silbert describes readymade code standard library can used computing cdf multivariate normal in python. scipy has way mentioned in blog, difficult find. approach based on paper alan genz’s.

from blog, how works.

from scipy.stats import mvn import numpy 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 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -