From 6b0b068a0711e1c829e70eec6c325dbeb35e469e Mon Sep 17 00:00:00 2001 From: Andriy Drozdyuk Date: Tue, 12 Sep 2023 14:11:50 -0400 Subject: [PATCH] Use weighted risk As per https://github.com/jxx123/simglucose/issues/63 --- simglucose/analysis/risk.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/simglucose/analysis/risk.py b/simglucose/analysis/risk.py index 1a205d90..0d7132a3 100644 --- a/simglucose/analysis/risk.py +++ b/simglucose/analysis/risk.py @@ -13,5 +13,8 @@ def risk_index(BG, horizon): rh = 10 * fBG[fBG > 0]**2 LBGI = np.nan_to_num(np.mean(rl)) HBGI = np.nan_to_num(np.mean(rh)) - RI = LBGI + HBGI + weight_rl = len(rl) / horizon + weight_rh = len(rh) / horizon + + RI = weight_rl * LBGI + weight_rh * HBGI return (LBGI, HBGI, RI)