Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/notebooks/chap17.ipynb
Views: 531
Modeling and Simulation in Python
Chapter 17
Copyright 2017 Allen Downey
Data
We have data from Pacini and Bergman (1986), "MINMOD: a computer program to calculate insulin sensitivity and pancreatic responsivity from the frequently sampled intravenous glucose tolerance test", Computer Methods and Programs in Biomedicine, 23: 113-122..
Here's what the glucose time series looks like.
And the insulin time series.
For the book, I put them in a single figure, using subplot
Interpolation
We have measurements of insulin concentration at discrete points in time, but we need to estimate it at intervening points. We'll use interpolate
, which takes a Series
and returns a function:
The return value from interpolate
is a function.
We can use the result, I
, to estimate the insulin level at any point in time.
I
can also take an array of time and return an array of estimates:
Here's what the interpolated values look like.
Exercise: Read the documentation of scipy.interpolate.interp1d
. Pass a keyword argument to interpolate
to specify one of the other kinds of interpolation, and run the code again to see what it looks like.
Exercise: Interpolate the glucose data and generate a plot, similar to the previous one, that shows the data points and the interpolated curve evaluated at the time values in ts
.