Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-25-2004, 12:01 AM   PM User | #1
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
More of a math question..

Hey guys,

I didn't really know where else to pose this question, but...

Let's say you've got
amt inc
5000 38
10000 29

So if you have 5000, you'd use 38. If you had 10000, you'd use 29.

Now I have a table of these pairs, in ascending order on amt for every 5000. (ie. 5000, 10000, 15000, 20000, ....).

The problem I'm facing is that if I have, say, 6000, I don't have a matching 'inc'. Now I can't use 38, or 29, but I have to use something in between. But that something has to be proportionate if 'amt' is 5500 or 8900.

I hope that makes sense so far.

Now I think this has something to do with numerical analysis, but I really just can't remember what or how to do this!

If anyone can help, I'd really appreciate it. If you require more information, just ask.

Thanks,
Sadiq.
sad69 is offline   Reply With Quote
Old 03-25-2004, 08:49 AM   PM User | #2
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
It's called interpolation.
You can think of graphically: Your (amt,inc) pairs are points on a 2-D plane, and you connect them with a line. You go along that line until you reach the desired value on the "amt" axis, and then you see where you are on the "inc" axis.
If you did any high-school algebra or analytical geometry (I don't know if that's the name you'd use there but I mean finding the equations for lines, circles, etc.), then you should have no problem taking it from here.
If there are still problems post back.

shmoove
shmoove is offline   Reply With Quote
Old 03-25-2004, 06:34 PM   PM User | #3
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
Heh, thanks shmoove!

Funny thing, I emailed an old professor (numerical analysis prof..), and you are correct. He's told me to use Newton Interpolation.

I looked up the formula and now I'm on my way!

Thanks again,
Sadiq.
sad69 is offline   Reply With Quote
Old 03-26-2004, 10:17 AM   PM User | #4
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Newton interpolation eh, care to explain it?? I've only ever looked at linear and geometric for 3d model animation.
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 03-26-2004, 05:50 PM   PM User | #5
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
You should probably research it, cuz I don't think I understand it all that well (like how it works..).

I just know the formula for Newton's Linear Interpolation.

INTERPOLATE - To insert a value between known values by using a procedure or algorithm specifically related to the known values.
(Google's definition).

Here's the formula:
y = y1 + (x - x1) * (y2 - y1) / (x2 - x1)

i.e.
to interpolate between:
x1 = 5000 y1 = 38
x2 = 10000 y2 = 29

y = 38 + (x - 5000) * (-9) / 5000

sample values: x = 5000 y = 38 left end
x = 10000 y = 29 right end
x = 7500 y = 33.5 middle
x = 6000 y = 36.2

Hope that helps,
Sadiq.
sad69 is offline   Reply With Quote
Old 03-26-2004, 08:42 PM   PM User | #6
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
Damn scientists always sticking their name everywhere....
shmoove is offline   Reply With Quote
Old 03-26-2004, 09:59 PM   PM User | #7
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
Hey you would too I'm sure! shmoove's Linear Interpolation... nice ring to it! lol

I remember in university when we were learning the different sorting algorithms, we tried to come up with our own, and we'd name them after ourselves. I had sadSort... lame, but it was funny back in the day.

Ciao,
Sadiq.
sad69 is offline   Reply With Quote
Old 03-27-2004, 10:13 AM   PM User | #8
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
Hehe, I know, I was just acting jealous. And posting after 5 beers didn't help either.
shmoove is offline   Reply With Quote
Old 03-27-2004, 10:54 AM   PM User | #9
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Hehe ...
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 11:23 AM.


Advertisement
Log in to turn off these ads.