nightscout / Trio

Trio - an automated insulin delivery system for iOS based on the OpenAPS algorithm with adaptations.
https://docs.diy-trio.org/en/latest/
MIT License
95 stars 485 forks source link

Reduce smoothing time window #27

Closed mountrcg closed 5 months ago

mountrcg commented 7 months ago

@avouspierre : Suggestion to use the Savitzky-Golay filter for smoothing only across 10min (3 values) instead of 30min (7 values)

I played around with the Smoothing algorithm and found out that it uses quite a large timeframe to base the filter on. It is 30 min at the moment. I created a rather noise Glucose simulation in the integrated GlucoseSimulator with a rather broader target goal of 70 - 150 to get more noise at https://github.com/nightscout/Open-iAPS/blob/f404fc49bfe4732dbb61c3a1b202d5b1f22ce178/FreeAPS/Sources/APS/CGM/GlucoseSimulatorSource.swift#L157

The smoothing result with a 10 minute window is suffficient in my view. Changed the graph settings a bit for better visual of smoothing effect.

new setting old setting
Simulator Screenshot - iPhone 15 Pro Max - 2024-03-22 at 19 11 57 Simulator Screenshot - iPhone 15 Pro Max - 2024-03-22 at 19 11 57
Same pic as place holder. Currently simulating with the original setting for comparison - takes a while.
mountrcg commented 7 months ago

In my view it is better to filter with less data. SG filter will use forecast into future for current reading, the longer the window width used for filtering the longer also the forecast time frame, introducing more uncertainty into the current smoothed value. If the smoothing result is ok with shorter window, that should be preferred.

mountrcg commented 5 months ago

Not really relevant.