Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (16.4k points)

In the assistance asset for the multivariate normal sampling function in SciPy, they give the accompanying example: 

x,y = np.random.multivariate_normal(mean,cov,5000).T

My question is fairly fundamental: what does the last .T really do? 

Thank you in advance, I realize it is genuinely straightforward. However, it is difficult to glance in Google for ".T".

1 Answer

0 votes
by (26.4k points)

The .T gets to the property T of the object, which turns out to be a NumPy array. The T attribute is the render of the array, see the documentation

Obviously, you are making arbitrary coordinates in the plane. The yield of multivariate_normal() may resemble this:

>>> np.random.multivariate_normal([0, 0], [[1, 0], [0, 1]], 5)  

array([[ 0.59589335,  0.97741328],

       [-0.58597307,  0.56733234],

       [-0.69164572,  0.17840394],

       [-0.24992978, -2.57494471],

       [ 0.38896689,  0.82221377]])

Below was the transpose of this matrix,

array([[ 0.59589335, -0.58597307, -0.69164572, -0.24992978,  0.38896689],

       [ 0.97741328,  0.56733234,  0.17840394, -2.57494471,  0.82221377]])

Interested to learn the concepts of python in detail? Come and join the python course to gain more knowledge in python

Watch this video tutorial on how to become a professional in python

Related questions

0 votes
1 answer
asked Oct 15, 2019 in Python by Sammy (47.6k points)
0 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories