Hao Zhang
Hao Zhang

Reputation: 257

bivariate standard normal variable in Python

I have a question about bivariate standard normal random variable.

Suppose

M(x,y,rho)=P

(X is less than x,Y is less than y) where X and Y are bivariate standard normal random variables with correlation rho.

How can I solve M in Python. Suppose I want to solveM(1,3,0.9). How can I solve it in Python?

I have searched numpy.random.multivariate_normal, but I am still confused.

Upvotes: 0

Views: 1044

Answers (1)

Bob Baxley
Bob Baxley

Reputation: 3751

You are trying to compute the CDF of a multivariate normal distribution. Here is a way to do it:

from scipy.stats import mvn
import numpy as np
low = np.array([-100, -100])
upp = np.array([1, 3])
mu = np.array([0, 0])
S = np.array([[1,0.9],[0.9,1]])
p,i = mvn.mvnun(low,upp,mu,S)
print p

The low bound array is an approximation in negative infinity. You can make those numbers more negative if you want more precision.

Upvotes: 1

Related Questions