LFD Book Forum

LFD Book Forum (http://book.caltech.edu/bookforum/index.php)
-   Homework 4 (http://book.caltech.edu/bookforum/forumdisplay.php?f=133)
-   -   *ANSWER* Stuck on #4 (http://book.caltech.edu/bookforum/showthread.php?t=4249)

jcmorales1564 04-29-2013 10:05 AM

Re: *ANSWER* Stuck on #4

Originally Posted by yaser (Post 10649)
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.


Elroch 04-30-2013 09:27 AM

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. :)

GB449 09-09-2013 09:53 PM

Re: *ANSWER* Stuck on #4

Originally Posted by IsidroHidalgo (Post 10646)
I think you have a typo, is'n it? For me a=(x_1y_1+x_2y_2)/(x_1^2+x_2^2):clueless:

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;

All times are GMT -7. The time now is 03:20 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, 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.