[HW 3.2d] Linear Interpolation in Visual Basic

“Create” a VBA formula that will operate like =LOOKUP and will do a basic interpolation.  The formula should be =INTERPOLATE(lookup value, x range, y range).  For example, given the below data set:

Pizzas Ounces of Cheese Required
10 65
20 85
30 105
40 125

The value of 35 interpolated in the above data would be 115.  This should be a strict linear interpolation, not a cubic spline.

Also, for this assignment, although you are welcome to try to write an interpolation function.  However, if you’d prefer not to reinvent the wheel, please search the internet for one that has already been written.  Create a comment at the top of the code to identify where you pulled it from and who the original author was.  Then prove to yourself that the code works as you expect.

One way to  test your new function is to compare it to the Yield Curve for US Treasuries.  What was average the interpolated yield on 15 year treasury bonds for yesterday, according the data provided at the website of the Treasury Department?  Does the formula return what you would otherwise expect?

http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield

Turn in both your code and your “proof”.

Advertisements

2 comments

  1. Erin Giles · · Reply

    I proved that my function works with the pizza example, however, I am struggling with applying it to the Yield Curve for US Treasuries. I am unsure of what to put for the lookup value, x range, and y range. Please let me know if you have any insight.

    Thanks!

    Like

    1. For a yield curve, you might have to convert the labels (2 yr, 3yr, 5 yr, etc.) into numbers. Perhaps that will help.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: