<jupyter_start><jupyter_text>Interpolation Via SciPyWe can perform interpolation in Hist using SciPy.<jupyter_code># Make the necessary imports.
from scipy import interpolate
from hist import Hist, axis
import matplotlib.pyplot as plt
import numpy as np
# We obtain evenly spaced numbers over the specified interval.
x = np.linspace(-27, 27, num=250, endpoint=True)

# Define a Hist object and fill it.
h = Hist.new.Reg(10, -30, 30).Double()
centers = h.axes[0].centers
weights = np.cos(-(centers ** 2) / 9.0) ** 2
h.fill(centers, weight=weights)<jupyter_output><empty_output><jupyter_text>Linear 1-DWe can obtain a linear interpolation by passion the `kind="linear"` argument in [interpolate.interp1d()](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html).<jupyter_code>linear_interp = interpolate.interp1d(h.axes[0].centers, h.values(), kind="linear")
h.plot()  # Plot the histogram
plt.plot(h.axes[0].centers, h.values(), "o")  # Mark the bin centers
plt.plot(x, linear_interp(x), "-.")  # Plot the Linear interpolation
plt.show()<jupyter_output><empty_output><jupyter_text>Cubic 1-DWe can obtain a cubic interpolation by passion the `kind="cubic"` argument in [interpolate.interp1d()](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html).<jupyter_code>cubic_interp = interpolate.interp1d(h.axes[0].centers, h.values(), kind="cubic")
h.plot()  # Plot the histogram
plt.plot(h.axes[0].centers, h.values(), "o")  # Mark the bin centers
plt.plot(x, cubic_interp(x), "--")  # Plot the Cubic interpolation
plt.show()<jupyter_output><empty_output><jupyter_text>We can also plot them both together to compare the interpolations.<jupyter_code>h.plot()  # Plot the histogram
plt.plot(h.axes[0].centers, h.values(), "o")  # Mark the bin centers
plt.plot(x, linear_interp(x), "-.")  # Plot the Linear interpolation
plt.plot(x, cubic_interp(x), "--")  # Plot the Cubic interpolation
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1453811206461383, 'fraction_numerical': 0.015648662291771833, 'mean_word_length': 5.858131487889273, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '478923', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 751, 'n_tokens_neox': 700, 'n_words': 166, 'path': 'docs/user-guide/notebooks/Interpolation.ipynb', 'repo_name': 'meliache/hist', 'size': '1981'}