I saw this example in the SciPy documentation:
x, y = np.random.multivariate_normal(mean, cov, 5000).T
What does the final .T actually do here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
.Taccesses the attributeTof the object, which happens to be a NumPy array. TheTattribute is the transpose of the array, see the documentation.Apparently you are creating random coordinates in the plane. The output of
multivariate_normal()might look like this:The transpose of this matrix is:
which can be conveniently separated in
xandyparts by sequence unpacking.