diff --git a/experiment/paper1_steps/poster_EVAN2019/some_experiment_EVAN.py b/experiment/paper1_steps/poster_EVAN2019/some_experiment_EVAN.py index 6ea0da2462482342c083b7aed7611877034756d5..0dae77395e58e2bce419e9da4413776e130fb75c 100644 --- a/experiment/paper1_steps/poster_EVAN2019/some_experiment_EVAN.py +++ b/experiment/paper1_steps/poster_EVAN2019/some_experiment_EVAN.py @@ -18,15 +18,15 @@ mpl.rcParams['hatch.linewidth'] = 0.3 def main_non_stationary_model_comparison(): - stop_loop = True + stop_loop = False for altitude in POSTER_ALTITUDES[:]: for trend_test_class in [GevLocationTrendTest, GevScaleTrendTest, GevLocationAndScaleTrendTest, - ComparisonAgainstMu, ComparisonAgainstSigma][::-1][-1:]: + ComparisonAgainstMu, ComparisonAgainstSigma][::-1][:]: vizualiser = get_full_altitude_visualizer(Altitude_Hypercube_Year_Visualizer, altitude=altitude, exact_starting_year=1958, reduce_strength_array=False, trend_test_class=trend_test_class, ) - vizualiser.save_to_file = False + # vizualiser.save_to_file = False vizualiser.visualize_massif_trend_test_one_altitude(poster_plot=True, write_text_on_massif=False) if stop_loop: return diff --git a/extreme_estimator/margin_fits/gev/gev_params.py b/extreme_estimator/margin_fits/gev/gev_params.py index 395032b551a9f18ff10ae347b2f9d03465ae705c..65c12f797117ad36201eed89b5af575377f6f4c6 100644 --- a/extreme_estimator/margin_fits/gev/gev_params.py +++ b/extreme_estimator/margin_fits/gev/gev_params.py @@ -2,6 +2,7 @@ from collections import OrderedDict from typing import List from cached_property import cached_property +from mpmath import euler, pi from extreme_estimator.extreme_models.utils import r from extreme_estimator.margin_fits.extreme_params import ExtremeParams @@ -78,6 +79,8 @@ class GevParams(ExtremeParams): return np.nan elif self.shape >= 1: return np.inf + elif self.shape == 0: + return self.location + self.scale * euler else: return self.location + self.scale * (self.g(k=1) - 1) / self.shape @@ -87,6 +90,8 @@ class GevParams(ExtremeParams): return np.nan elif self.shape >= 0.5: return np.inf + elif self.shape == 0.0: + return (self.scale * pi) ** 2 / 6 else: return ((self.scale / self.shape) ** 2) * (self.g(k=2) - self.g(k=1) ** 2) diff --git a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_params.py b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_params.py index 0b19d97afc17cd34e1a00bf3ef2dc75539e8b059..0e7d8903bfcb806328be0288f8288928b3c4be48 100644 --- a/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_params.py +++ b/test/test_extreme_estimator/test_margin_fits/test_gev/test_gev_params.py @@ -1,6 +1,9 @@ import unittest +from mpmath import euler + import numpy as np +from scipy.special.cython_special import gamma from extreme_estimator.margin_fits.gev.gev_params import GevParams @@ -33,6 +36,24 @@ class TestGevParams(unittest.TestCase): self.assertEqual(gev_params.variance, np.inf) self.assertEqual(gev_params.std, np.inf) + def test_mean(self): + mu = 1.0 + sigma = 1.0 + gev_params = GevParams(loc=mu, shape=0.0, scale=sigma) + self.assertEqual(gev_params.mean, mu + sigma * euler) + chi = 0.5 + gev_params = GevParams(loc=mu, shape=chi, scale=sigma) + self.assertEqual(gev_params.mean, mu + sigma * (gamma(1 - 0.5) - 1) / chi) + + def test_variance(self): + mu = 1.0 + sigma = 1.0 + gev_params = GevParams(loc=mu, shape=0.0, scale=sigma) + self.assertEqual(gev_params.variance, ((sigma * np.math.pi) ** 2) / 6) + chi = 0.25 + gev_params = GevParams(loc=mu, shape=chi, scale=sigma) + self.assertEqual(gev_params.variance, ((sigma / chi) ** 2) * (gamma(1 - 2 * chi) - (gamma(1 - chi) ** 2))) + if __name__ == '__main__': unittest.main()