View Single Post
Old 04-27-2013, 06:28 PM
gmacaree gmacaree is offline
Junior Member
Join Date: Apr 2013
Posts: 2
Default Re: Question 4 linear regression hypothesis

Originally Posted by View Post
Apparently quite some people got the same wrong answer (g_hat = 1.4) according to this post:

I am desperately in need of suggestion here to figure out the reason. My thought on this question is pretty straight forward: generate a two point sample:
Xsamples = (rand(2, 1)-0.5)*2;
yn = sin(Xsamples.*pi);
a is calculated by
regress(yn, Xsamples) (to minimize the squared error)
Repeat 1000 times and take the average of a (because of uniform distributed input X), that gives me 1.42.

Any advice is appreciated.
Am having exactly the same issue -- I was using a lazy point-fitting technique and came up with an answer matching one of the choices, but then as soon as I used a more rigourous solution for through-the-origin regression I end up with a slope of 1.42. That's obviously incorrect but I'm slightly baffled as to why I get it right when I do it wrong and wrong when I do it right!
Reply With Quote