# [SciPy-User] Newbie Question :: Natural Cubic Spline

hello world helloworld777@hotmail....
Sun Oct 25 16:58:51 CDT 2009

```Hello,

Thanks for the example.  It is greatly appreciated.   Would you have an example of a monotonic cubic spline?

Thanks,
Alex

From: helloworld777@hotmail.com
To: scipy-user@scipy.org
Subject: Newbie Question :: Natural Cubic Spline
Date: Wed, 21 Oct 2009 15:48:19 -0500

Hello:

I am new to Python and the SciPy libraries and I was wondering if someone could help me with the following.

Given the following x and y : values

x_list = [33,              56,     56.00000000002,       147,    238,    329,    420,    511,    602,    693,    791]

y_list = [0.99974,    0.99949,            0.99949,   0.99816,0.99631,0.99383,0.99043,0.98610,0.98078,0.97460,0.96704]

I want to use a Natural Cubic Spline in order to determine the points at the following values:

interp_x_points    = [31,62,92,123,153,184,215,243,274,304,335,365,396,427,457,488,518,549,580,608,639,669,700]

I have looked through the documentation and have had a tough time determining the correct syntax or which function to use.

I was wondering what would be the SciPy syntax for the following:
Also, does scipy have the ability to extrapolate if a give X value is outside a specified range?
In this example, please notice interp_x_poiints has a value (31) which is outside of the x_list range.

============================
my_spline_object = NaturalCubicSpline(x_list, y_list)
for interp_x_value in interp_x_points:
interp_y_value = my_spline_object(interp_x_value)  # return a floating value
print interp_y_value

Many Thanks

Hotmail: Free, trusted and rich email service. Get it now.
_________________________________________________________________