LFD Book Forum  

Go Back   LFD Book Forum > Course Discussions > Online LFD course > Homework 4

Thread Tools Display Modes
Old 04-29-2013, 11:05 AM
jcmorales1564 jcmorales1564 is offline
Join Date: Apr 2013
Posts: 12
Default Re: *ANSWER* Stuck on #4

Originally Posted by yaser View Post
Your answer should agree with the given answer to two-decimal-digit accuracy as stated in the problem, or else be considered "none of the above."
Thank you, professor. I responded a few minutes ago, apparently just at the same time that you did. I had not seen your reply.

Reply With Quote
Old 04-30-2013, 10:27 AM
Elroch Elroch is offline
Invited Guest
Join Date: Mar 2013
Posts: 143
Default Re: *ANSWER* Stuck on #4

One absurdly simple way to get a handle on the plausibility of the result all of us doubted is to see what the range of possible slopes is, and guess it might be near the middle.

Observe that if two points are very near the origin, the slope can be \pi but no higher. If they are at the furthest extremes, the slope can be zero, but no lower. The mean of this range of possible slopes is 1.57.
Reply With Quote
Old 09-09-2013, 10:53 PM
GB449 GB449 is offline
Join Date: Aug 2013
Posts: 20
Default Re: *ANSWER* Stuck on #4

Originally Posted by IsidroHidalgo View Post
I think you have a typo, is'n it? For me a=(x_1y_1+x_2y_2)/(x_1^2+x_2^2)
I have simulated 100K points using this formula for slope and taken the average. I have run this a number of times but each time I get a different slope all of which are small numbers like +/- 0.00X

The random points (x1, y1) and (x2, y2) I generated are all between -1 and 1. Is the slope I am getting small because the random numbers are between -1 and 1? After all, I am dividing by 100K.

Here's the code
double slope = ((x1*y1) + (x2*y2)) / ((x1*x1) + (x2*x2));

I sum the slopes for each point and compute average
AverageSlope = SumSlope / (double) NoOfPoints;
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 02:11 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
The contents of this forum are to be used ONLY by readers of the Learning From Data book by Yaser S. Abu-Mostafa, Malik Magdon-Ismail, and Hsuan-Tien Lin, and participants in the Learning From Data MOOC by Yaser S. Abu-Mostafa. No part of these contents is to be communicated or made accessible to ANY other person or entity.