How to do it...

The probability of a given value in a multivariate Gaussian distribution is calculated as follows:

  1. Import the relevant packages:
from scipy.stats import multivariate_normalimport numpy as np
  1. Initialize the array of variables:
x = np.array([[1,2], [3,4]])

In the preceding code snippet, we have initialized two data points located in a two-dimensional space.

  1. Calculate the probability associated with the two data points using the pdf function, where the mean and variance along the two dimensions is given, as follows:
multivariate_normal.pdf(x, mean=[0, 1], cov=[5, 2])array([ 0.0354664 ,  0.00215671])

The output of the preceding code results in probabilities associated with the first data point [1, 2] and the second data point ...

Get SciPy Recipes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.