r/pythonhelp • • Nov 10 '19

Not understanding numpy.random

Hey guys,
I really cant get my head around what is happening in this Code. What is numpy.random.multivariate_normal returning. What is x and what is y. And what are those red lines representing. Would be nice if someone could explain like im five. I really dont understand what those samples represent

Note: I am the one who wrote the code, it was an excersice I had to do where I basically just followed what the lection told me to do. Here is the excersice

2 Upvotes

4 comments sorted by

1

u/Best_Caterpillar Nov 11 '19

do you know what the normal distribution is? the x and y are literal x and y pairs from that sample. the red line is the relationship using the b0 and b1 coeficents that you got in the biddle of your code

side note, it really doesnt help you to overload the variables like you did, cause halfway through you change the meaning and that is not helping your comprehension any

1

u/Ipsoka Nov 11 '19 edited Nov 11 '19

Even though I have a hard time getting my head around the concept i think i understand it kinda. But what does the function exactly do. What is a sample. Does the function plug in a random x,so a random probability, and calculates the corresponding y value with the mean and cov i gave it?

Edit:Thanks for the tipp

1

u/Best_Caterpillar Nov 12 '19

your problem here is understanding statistics and not programming. If you are getting confused on the matter you really really should be talking to a TA or professor because the concepts you are asking about are really really foundational to stats, and there is a lot to unpack.

as a very short answer to your question, look of the difference between a parameter and a statistic. the function is creating observations from some distribution with the paramiters you specified, and when you are creating the regression line you are computing statistics based off your collection of sample values

1

u/someoneonboard1 Nov 11 '19

Did you go through this numpy documentation? It pretty much explains everything. There is even one example just like the one you have in your Code.

https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.random.multivariate_normal.html