.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_summary-exercises_auto_examples_plot_gumbell_wind_speed_prediction.py: The Gumbell distribution ========================= Generate the exercise results on the Gumbell distribution .. image:: /intro/summary-exercises/auto_examples/images/sphx_glr_plot_gumbell_wind_speed_prediction_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np from scipy.interpolate import UnivariateSpline import matplotlib.pyplot as plt def gumbell_dist(arr): return -np.log(-np.log(arr)) years_nb = 21 wspeeds = np.load('sprog-windspeeds.npy') max_speeds = np.array([arr.max() for arr in np.array_split(wspeeds, years_nb)]) sorted_max_speeds = np.sort(max_speeds) cprob = (np.arange(years_nb, dtype=np.float32) + 1)/(years_nb + 1) gprob = gumbell_dist(cprob) speed_spline = UnivariateSpline(gprob, sorted_max_speeds, k=1) nprob = gumbell_dist(np.linspace(1e-3, 1-1e-3, 1e2)) fitted_max_speeds = speed_spline(nprob) fifty_prob = gumbell_dist(49./50.) fifty_wind = speed_spline(fifty_prob) plt.figure() plt.plot(sorted_max_speeds, gprob, 'o') plt.plot(fitted_max_speeds, nprob, 'g--') plt.plot([fifty_wind], [fifty_prob], 'o', ms=8., mfc='y', mec='y') plt.plot([fifty_wind, fifty_wind], [plt.axis()[2], fifty_prob], 'k--') plt.text(35, -1, r'$V_{50} = %.2f \, m/s$' % fifty_wind) plt.xlabel('Annual wind speed maxima [$m/s$]') plt.ylabel('Gumbell cumulative probability') plt.show() **Total running time of the script:** ( 0 minutes 0.015 seconds) .. _sphx_glr_download_intro_summary-exercises_auto_examples_plot_gumbell_wind_speed_prediction.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_gumbell_wind_speed_prediction.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_gumbell_wind_speed_prediction.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_