Skip to content

Commit 8073de8

Browse files
committed
Distinguish between type 1 and 2 conditional biases
1 parent 80799a0 commit 8073de8

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

pysteps/tests/test_detcontscores.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
(fct_data, obs_data, ('NMSE'), None, None, [0.113711]),
4141
# Root Mean Square Error
4242
(fct_data, obs_data, ('RMSE'), None, None, [8.009370]),
43-
# Beta
44-
(fct_data, obs_data, ('beta'), None, None, [0.498200]),
43+
# Beta1
44+
(fct_data, obs_data, ('beta1'), None, None, [0.498200]),
45+
# Beta2
46+
(fct_data, obs_data, ('beta2'), None, None, [0.591673]),
4547
# reduction of variance
4648
(fct_data, obs_data, ('RV'), None, None, [-0.054622]),
4749
# debiased RMSE

pysteps/verification/detcontscores.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def det_cont_fct(pred, obs, scores="", axis=None, conditioning=None, thr=0.0):
4040
+------------+--------------------------------------------------------+
4141
| Name | Description |
4242
+============+========================================================+
43-
| beta | linear regression slope (conditional bias) |
43+
| beta1 | linear regression slope (type 1 conditional bias) |
44+
+------------+--------------------------------------------------------+
45+
| beta2 | linear regression slope (type 2 conditional bias) |
4446
+------------+--------------------------------------------------------+
4547
| corr_p | pearson's correleation coefficien (linear correlation) |
4648
+------------+--------------------------------------------------------+
@@ -98,6 +100,12 @@ def det_cont_fct(pred, obs, scores="", axis=None, conditioning=None, thr=0.0):
98100
Note that "scatter" is the only score that will be computed in dB units of
99101
the multiplicative error, i.e.: 10*log10(pred/obs).
100102
103+
beta1 measures the degree of conditional bias of the observations given the
104+
forecasts (type 1).
105+
106+
beta2 measures the degree of conditional bias of the forecasts given the
107+
observations (type 2).
108+
101109
The normalized MSE is computed as NMSE = E[(pred - obs)^2]/E[(pred + obs)^2].
102110
103111
The debiased RMSE is computed as DRMSE = sqrt(RMSE - ME^2).
@@ -116,6 +124,10 @@ def det_cont_fct(pred, obs, scores="", axis=None, conditioning=None, thr=0.0):
116124
precipitation measurement in a mountainous region. Q.J.R. Meteorol. Soc.,
117125
132: 1669-1692. doi:10.1256/qj.05.190
118126
127+
Potts, J. (2012), Chapter 2 - Basic concepts. Forecast verification: a
128+
practitioner’s guide in atmospheric sciences, I. T. Jolliffe, and D. B.
129+
Stephenson, Eds., Wiley-Blackwell, 11–29.
130+
119131
See also
120132
--------
121133
@@ -420,7 +432,9 @@ def det_cont_fct_compute(err, scores=""):
420432
+------------+--------------------------------------------------------+
421433
| Name | Description |
422434
+============+========================================================+
423-
| beta | linear regression slope (conditional bias) |
435+
| beta1 | linear regression slope (type 1 conditional bias) |
436+
+------------+--------------------------------------------------------+
437+
| beta2 | linear regression slope (type 2 conditional bias) |
424438
+------------+--------------------------------------------------------+
425439
| corr_p | pearson's correleation coefficien (linear correlation) |
426440
+------------+--------------------------------------------------------+
@@ -496,10 +510,15 @@ def get_iterable(x):
496510
corr_p = err["cov"] / np.sqrt(err["vobs"]) / np.sqrt(err["vpred"])
497511
result["corr_p"] = corr_p
498512

499-
# beta (linear regression slope)
500-
if score_ in ["beta", ""]:
501-
beta = err["cov"] / err["vpred"]
502-
result["beta"] = beta
513+
# beta1 (linear regression slope)
514+
if score_ in ["beta", "beta1", ""]:
515+
beta1 = err["cov"] / err["vpred"]
516+
result["beta1"] = beta1
517+
518+
# beta2 (linear regression slope)
519+
if score_ in ["beta2", ""]:
520+
beta2 = err["cov"] / err["vobs"]
521+
result["beta2"] = beta2
503522

504523
# debiased RMSE
505524
if score_ in ["drmse", ""]:

pysteps/verification/interface.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def get_method(name, type="deterministic"):
5353
+------------+--------------------------------------------------------+
5454
| SEDI | symmetric extremal dependency index |
5555
+------------+--------------------------------------------------------+
56-
| beta | linear regression slope (conditional bias) |
56+
| beta1 | linear regression slope (type 1 conditional bias) |
57+
+------------+--------------------------------------------------------+
58+
| beta2 | linear regression slope (type 2 conditional bias) |
5759
+------------+--------------------------------------------------------+
5860
| corr_p | pearson's correleation coefficien (linear correlation) |
5961
+------------+--------------------------------------------------------+
@@ -120,25 +122,35 @@ def get_method(name, type="deterministic"):
120122
121123
Multiplicative scores can be computed by passing log-tranformed values.
122124
Note that "scatter" is the only score that will be computed in dB units of
123-
the multiplicative error, i.e.: 10log10(pred/obs).
125+
the multiplicative error, i.e.: 10*log10(pred/obs).
126+
127+
beta1 measures the degree of conditional bias of the observations given the
128+
forecasts (type 1).
129+
130+
beta2 measures the degree of conditional bias of the forecasts given the
131+
observations (type 2).
124132
125-
The debiased RMSE is computed as DRMSE = sqrt(RMSE - ME^2)
133+
The normalized MSE is computed as NMSE = E[(pred - obs)^2]/E[(pred + obs)^2].
126134
127-
The reduction of variance score is computed as RV = 1 - MSE/Var(obs)
135+
The debiased RMSE is computed as DRMSE = sqrt(RMSE - ME^2).
136+
137+
The reduction of variance score is computed as RV = 1 - MSE/Var(obs).
128138
129139
Score names denoted by * can only be computed offline, meaning that the
130-
these cannot be update using _init, _accum and _compute methods of this
140+
these cannot be computed using _init, _accum and _compute methods of this
131141
module.
132142
133-
Score names denoted by * can only be computed offline.
134-
135143
References
136144
----------
137145
138146
Germann, U. , Galli, G. , Boscacci, M. and Bolliger, M. (2006), Radar
139147
precipitation measurement in a mountainous region. Q.J.R. Meteorol. Soc.,
140148
132: 1669-1692. doi:10.1256/qj.05.190
141149
150+
Potts, J. (2012), Chapter 2 - Basic concepts. Forecast verification: a
151+
practitioner’s guide in atmospheric sciences, I. T. Jolliffe, and D. B.
152+
Stephenson, Eds., Wiley-Blackwell, 11–29.
153+
142154
"""
143155

144156
if name is None:
@@ -178,6 +190,8 @@ def f(fct, obs, **kwargs):
178190
# continuous
179191
elif name in [
180192
"beta",
193+
"beta1",
194+
"beta2",
181195
"corr_p",
182196
"corr_s",
183197
"drmse",

0 commit comments

Comments
 (0)