@@ -27,7 +27,6 @@ In addition to what's in Anaconda, this lecture will need the following librarie
2727tags: [hide-output]
2828---
2929!pip install --upgrade quantecon
30- !pip install interpolation
3130```
3231
3332## Overview
@@ -38,10 +37,28 @@ Let's start with following imports:
3837import numpy as np
3938import matplotlib.pyplot as plt
4039from scipy.optimize import root
41- from interpolation.splines import eval_linear, UCGrid, nodes
4240from quantecon import optimize, MarkovChain
4341from numba import njit, prange, float64
4442from numba.experimental import jitclass
43+
44+ # NumPy-based replacements for interpolation package functions
45+ def UCGrid(bounds):
46+ """Uniform coordinate grid."""
47+ return (bounds,)
48+
49+ def nodes(x_grid):
50+ """Extract grid nodes."""
51+ x_min, x_max, x_num = x_grid[0]
52+ grid_points = np.linspace(x_min, x_max, int(x_num))
53+ return grid_points.reshape(-1, 1)
54+
55+ @njit
56+ def eval_linear(x_grid, y_values, x_points):
57+ """Linear interpolation using numpy."""
58+ x_min, x_max, x_num = x_grid[0]
59+ grid_points = np.linspace(x_min, x_max, int(x_num))
60+ result = np.interp(x_points, grid_points, y_values)
61+ return result[0]
4562```
4663
4764In {doc}` an earlier lecture <opt_tax_recur> ` , we described a model of
0 commit comments