Skip to content

Commit

Permalink
add final example
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengp0 committed Aug 4, 2023
1 parent ca30e1c commit b188077
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,36 @@ XSpline can be used to obtain definite integrals.
ax[0].plot(x, iy)
ax[1].plot(x, idesign_mat)
.. image:: images/readme_usage_2.png
.. image:: images/readme_usage_2.png

XSpline can extrapolate with different polynomial options

.. code-block:: python
np.random.seed(123)
# constant extrapolation one the left and linear extrapolation on the right
spline = XSpline(
knots=[0, 0.25, 0.5, 0.75, 1],
degree=3,
ldegree=0,
rdegree=1,
coef=np.random.randn(len(spline)),
)
x = np.arange(-0.5, 1.51, 0.01)
y, design_mat = spline(x), spline.get_design_mat(x)
fig, ax = plt.subplots(1, 2, figsize=(10, 3))
ax[0].plot(x, y)
ax[1].plot(x, design_mat)
for i in range(len(ax)):
ax[i].vlines(
[0, 1],
ymin=0,
ymax=1,
transform=ax[i].get_xaxis_transform(),
linestyle="--",
linewidth=1,
color="grey",
)
.. image:: images/readme_usage_3.png
Binary file added images/readme_usage_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b188077

Please sign in to comment.