Commit cdbdb269 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[EXTREME ESTIMATOR] fix quantile function. add test.

parent 451ccf55
No related merge requests found
Showing with 23 additions and 5 deletions
+23 -5
......@@ -15,6 +15,7 @@ class GevParams(object):
GEV_QUANTILE_100 = 'quantile 100'
GEV_QUANTILE_1000 = 'quantile 1000'
GEV_QUANTILE_NAMES = [GEV_QUANTILE_10, GEV_QUANTILE_100, GEV_QUANTILE_1000]
GEV_QUANTILE_P_VALUES = [0.9, 0.99, 0.999]
# GEV values
GEV_VALUE_NAMES = GEV_PARAM_NAMES + GEV_QUANTILE_NAMES[:-1]
......@@ -51,11 +52,7 @@ class GevParams(object):
@property
def quantile_name_to_p(self) -> dict:
return {
self.GEV_QUANTILE_10: 0.1,
self.GEV_QUANTILE_100: 0.01,
self.GEV_QUANTILE_1000: 0.001,
}
return dict(zip(self.GEV_QUANTILE_NAMES, self.GEV_QUANTILE_P_VALUES))
@property
def quantile_dict(self) -> dict:
......
import unittest
import numpy as np
from extreme_estimator.extreme_models.utils import r, set_seed_r
from extreme_estimator.gev.gevmle_fit import GevMleFit
from extreme_estimator.gev_params import GevParams
class TestGevParams(unittest.TestCase):
def test_quantile(self):
# For GEV(1,1,1), the repartition function is exp(-y^-1) the formula for the quantile p is -1/log(p)
gev_params = GevParams(loc=1.0, shape=1.0, scale=1.0)
quantile_dict = gev_params.quantile_dict
for quantile_name, p in gev_params.quantile_name_to_p.items():
self.assertAlmostEqual(- 1 / np.log(p), quantile_dict[quantile_name])
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment