Skip to content

Commit

Permalink
refactor: t-test EvaluationResult() now includes value of alpha, so i…
Browse files Browse the repository at this point in the history
…t is not necessary to set it again when plotting. plot_comparison_test() includes a default legend that explains the symbology therein.
  • Loading branch information
pabloitu committed Aug 27, 2024
1 parent 229d0d8 commit 7306329
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion csep/core/poisson_evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def paired_t_test(forecast, benchmark_forecast, observed_catalog,
result.name = 'Paired T-Test'
result.test_distribution = (out['ig_lower'], out['ig_upper'])
result.observed_statistic = out['information_gain']
result.quantile = (out['t_statistic'], out['t_critical'])
result.quantile = (out['t_statistic'], out['t_critical'], alpha)
result.sim_name = (forecast.name, benchmark_forecast.name)
result.obs_name = observed_catalog.name
result.status = 'normal'
Expand Down
3 changes: 2 additions & 1 deletion csep/utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ def plot_comparison_test(
if plot_args["legend"]:
# Add custom legend to explain results
legend_elements = [
Line2D([0], [0], color="red", lw=2, label="T-test rejected"),
Line2D([0], [0], color="red", lw=2,
label=f"T-test rejected ($\\alpha = {results_t[0].quantile[-1]}$)"),
Line2D([0], [0], color="green", lw=2, label="T-test non-rejected"),
Line2D([0], [0], color="gray", lw=2, label="T-test indistinguishable"),
Line2D(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def rand(limit=10, offset=0.0):
t_result.observed_statistic - rand(5),
t_result.observed_statistic + rand(5),
]

t_result.quantile = (None, None, 0.05)
if numpy.random.random() < 0.05: # sim possible infinite values
t_result.observed_statistic = -numpy.inf
t_tests.append(t_result)
Expand Down

0 comments on commit 7306329

Please sign in to comment.