Numpy's Multivariate Normal example is not clear

179 views Asked by At

I am not sure if this question fits to numpy users or mathematicians. I don't understand how the numpy.random.multivariate_normal's example works.

In the bottom of the documentation, it generates a few random values given a mean and covariance matrix,

mean = (1, 2)
cov = [[1, 0], [0, 1]]
x = np.random.multivariate_normal(mean, cov, (3, 3))

and then says:

The following is probably true, given that 0.6 is roughly twice the standard deviation. list((x[0,0,:] - mean) < 0.6)

I understand that this is coming from the empirical rule but I don't know how the standard deviation is 0.3. Given that the variance is 1 in each axis, the std (square root of variance) should be 1 too, not 0.3.

Moreover, for multivariate variables, this 95% rule doesn't hold anymore.

Can anyone help me through this?

1

There are 1 answers

1
Michael On

The sentence you refer to, refers to the property of a normal distribution in general (enter link description here),

enter image description here

and not to some NumPy-specific functionality. As you normalize the samples you ger, i.e., reduce the mean, the distribution is shifted around 0, and given that the std of the samples is 0.3, than most of the samples will be generated in range which is less than 3*0.3 = 0.9 from the mean, viz. 0, with the following proportion:

  • ~68.27% in range [-0.3, +0.3]
  • ~95.45% in range of [-0.6, +0.6]
  • ~99.73% in range of [-0.9, +0.9]

so, it follows that roughly 95% of the times the X you get in the vector you produce will be smaller than 0.6, if the std=0.3.

Cheers