From a40956e02110b36243651d23a0428fc3a3691720 Mon Sep 17 00:00:00 2001 From: Le Roux Erwan <erwan.le-roux@irstea.fr> Date: Mon, 11 Feb 2019 14:54:50 +0100 Subject: [PATCH] [SLIDES] add plot for slides --- thesis_report/slides.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 thesis_report/slides.py diff --git a/thesis_report/slides.py b/thesis_report/slides.py new file mode 100644 index 00000000..8e4852de --- /dev/null +++ b/thesis_report/slides.py @@ -0,0 +1,41 @@ +import numpy as np +import matplotlib.pyplot as plt + +from extreme_estimator.extreme_models.utils import r, set_seed_r + + +def snowfall_plot(flip=False): + set_seed_r(seed=21) + mean, sd = 200, 50 + lim = 200 + x = np.linspace(max(0, mean-lim), mean+lim, 1000) + y = r.dnorm(x, mean=mean, sd=sd) + + if flip: + plt.plot(y, x) + else: + plt.plot(x, y) + plt.legend() + plt.xlabel('snowfall S in mm') + plt.ylabel('P(S)') + + level_to_color = {0.99: 'r', + 0.5: 'g'} + for level, color in level_to_color.items(): + quantile = r.qnorm(p=level, mean=mean, sd=sd) + print(level, color, quantile) + if flip: + plt.plot(r.dnorm(quantile, mean=mean, sd=sd), quantile, color + 'o') + else: + plt.plot(quantile, r.dnorm(quantile, mean=mean, sd=sd), color + 'o') + + # Place the sample + if not flip: + n = 50 + plt.plot(r.rnorm(n=n, mean=mean, sd=sd), np.zeros(n), 'ko') + + plt.show() + + +if __name__ == '__main__': + snowfall_plot(flip=True) -- GitLab