From 717c515bc4e382df9a53936cbca7d72d3581e2b7 Mon Sep 17 00:00:00 2001 From: pabloitu_home Date: Thu, 22 Jul 2021 18:29:05 +0200 Subject: [PATCH] Added percentile argument in plot_args to modify the default confidence interval. --- csep/utils/plots.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/csep/utils/plots.py b/csep/utils/plots.py index 1f8a9d7c..4dcb1114 100644 --- a/csep/utils/plots.py +++ b/csep/utils/plots.py @@ -1307,14 +1307,15 @@ def plot_poisson_consistency_test(eval_results, normalize=False, one_sided_lower capsize = plot_args.get('capsize', 4) hbars = plot_args.get('hbars', True) tight_layout = plot_args.get('tight_layout', True) + percentile = plot_args.get('percentile', 95) fig, ax = pyplot.subplots(figsize=figsize) xlims = [] for index, res in enumerate(results): # handle analytical distributions first, they are all in the form ['name', parameters]. if res.test_distribution[0] == 'poisson': - plow = scipy.stats.poisson.ppf(0.025, res.test_distribution[1]) - phigh = scipy.stats.poisson.ppf(0.975, res.test_distribution[1]) + plow = scipy.stats.poisson.ppf((1 - percentile/100.)/2., res.test_distribution[1]) + phigh = scipy.stats.poisson.ppf(1 - (1 - percentile/100.)/2., res.test_distribution[1]) observed_statistic = res.observed_statistic # empirical distributions else: @@ -1326,11 +1327,11 @@ def plot_poisson_consistency_test(eval_results, normalize=False, one_sided_lower observed_statistic = res.observed_statistic # compute distribution depending on type of test if one_sided_lower: - plow = numpy.percentile(test_distribution, 5) + plow = numpy.percentile(test_distribution, 100 - percentile) phigh = numpy.percentile(test_distribution, 100) else: - plow = numpy.percentile(test_distribution, 2.5) - phigh = numpy.percentile(test_distribution, 97.5) + plow = numpy.percentile(test_distribution, (100 - percentile)/2.) + phigh = numpy.percentile(test_distribution, 100 - (100 - percentile)/2.) if not numpy.isinf(observed_statistic): # Check if test result does not diverges low = observed_statistic - plow