[TAG] Brother, can you spare a function?
Fri Sep 17 19:14:27 MSD 2010
On Fri, Sep 17, 2010 at 10:37 AM, Ben Okopnik <ben at linuxgazette.net> wrote:
> On Fri, Sep 17, 2010 at 10:26:08AM -0400, Anderson Silva wrote:
> > On Fri, Sep 17, 2010 at 9:14 AM, Ben Okopnik <ben at linuxgazette.net>
> > I need to come up with a "slope" function that will return my weight
> > any point between 6/26 and 9/16.
> > I am not sure if I can attach files to the list, I've attached a quick
> chart I
> > drew with your data points.
> Yep, it came through.
> > The slope is negative, what you have to do now, is pick 2 points on the
> > and find out the length of X and Y for those to points.
> > Your slope will be: change in Y / change in X
> Yes. The problem is in doing that portably. In other words, for any N
> data points, can I select some M intervals and have the function
> generate the correct values for the appropriate X and Y?
> It's easy enough to do this manually on a spreadsheet; I want to
> replicate the functionality of what that spreadsheet engine is doing.
> > Since we are talking about dates, we may want to convert the dates to
> units of
> > days, like, 10 in 10 days like on the image.
> As I'd mentioned, I calculated the date values in seconds since the Unix
> epoch. That's not much of an issue.
> > so, you could pick a point like:
> > 300 - 334 / 60 - 0 = -34/60 which is approximately a slope of -1/2
> Whoops - that won't work. The slope is going to be different at various
> points between 300 and 334 - there are several data points between them.
> That's precisely the problem. Otherwise, I could just take the end
> points, calculate one slope, and be done.
> * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
> TAG mailing list
> TAG at lists.linuxgazette.net
Understood, can you then just apply the slope formula between 2 points:
(x1,y1) and (x2,y2)?
m being the slope, m = (y2-y1)/(x2-x1) ??? (with x2 != x1)
Again, just spitting out stuff :-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the TAG