.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "intro/scipy/summary-exercises/auto_examples/plot_cumulative_wind_speed_prediction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_intro_scipy_summary-exercises_auto_examples_plot_cumulative_wind_speed_prediction.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_scipy_summary-exercises_auto_examples_plot_cumulative_wind_speed_prediction.py: Cumulative wind speed prediction ================================ Generate the image cumulative-wind-speed-prediction.png for the interpolate section of scipy.rst. .. GENERATED FROM PYTHON SOURCE LINES 8-33 .. image-sg:: /intro/scipy/summary-exercises/auto_examples/images/sphx_glr_plot_cumulative_wind_speed_prediction_001.png :alt: plot cumulative wind speed prediction :srcset: /intro/scipy/summary-exercises/auto_examples/images/sphx_glr_plot_cumulative_wind_speed_prediction_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(42.722222222222214, 0.5, 'Cumulative probability') | .. code-block:: Python import numpy as np import scipy as sp import matplotlib.pyplot as plt max_speeds = np.load("max-speeds.npy") years_nb = max_speeds.shape[0] cprob = (np.arange(years_nb, dtype=np.float32) + 1) / (years_nb + 1) sorted_max_speeds = np.sort(max_speeds) speed_spline = sp.interpolate.UnivariateSpline(cprob, sorted_max_speeds) nprob = np.linspace(0, 1, 100) fitted_max_speeds = speed_spline(nprob) fifty_prob = 1.0 - 0.02 fifty_wind = speed_spline(fifty_prob) plt.figure() plt.plot(sorted_max_speeds, cprob, "o") plt.plot(fitted_max_speeds, nprob, "g--") plt.plot([fifty_wind], [fifty_prob], "o", ms=8.0, mfc="y", mec="y") plt.text(30, 0.05, rf"$V_{{50}} = {fifty_wind:.2f} \, m/s$") plt.plot([fifty_wind, fifty_wind], [plt.axis()[2], fifty_prob], "k--") plt.xlabel("Annual wind speed maxima [$m/s$]") plt.ylabel("Cumulative probability") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.074 seconds) .. _sphx_glr_download_intro_scipy_summary-exercises_auto_examples_plot_cumulative_wind_speed_prediction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cumulative_wind_speed_prediction.ipynb <plot_cumulative_wind_speed_prediction.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cumulative_wind_speed_prediction.py <plot_cumulative_wind_speed_prediction.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_cumulative_wind_speed_prediction.zip <plot_cumulative_wind_speed_prediction.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_