SeitaBV / timely-beliefs

Model data as beliefs (at a certain time) about events (at a certain time).
MIT License
34 stars 6 forks source link

Propagate beliefs #109

Closed Flix6x closed 2 years ago

Flix6x commented 2 years ago

I encountered the following use case, where I needed to do some computation on 3 sensors that had information about the same event start, but with 3 different belief times. At the first 2 belief times, not all information was known, but at the third belief time all information was known. It just wasn't propagated yet. This PR implements the required util function to propagate beliefs over time.

That is:

                                                                                      temp_air  \
event_start               belief_time               source    cumulative_probability             
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                          NaN   
                          2022-07-01 01:10:41+02:00 simulator 0.5                        13.61   
                          2022-07-01 02:10:32+02:00 simulator 0.5                          NaN   
                                                                                      wind_speed  \
event_start               belief_time               source    cumulative_probability               
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                            NaN   
                          2022-07-01 01:10:41+02:00 simulator 0.5                            NaN   
                          2022-07-01 02:10:32+02:00 simulator 0.5                           2.88   
                                                                                      cloud_cover  
event_start               belief_time               source    cumulative_probability               
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                            0.94  
                          2022-07-01 01:10:41+02:00 simulator 0.5                             NaN  
                          2022-07-01 02:10:32+02:00 simulator 0.5                             NaN  

Should become:

                                                                                      temp_air  \
event_start               belief_time               source    cumulative_probability             
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                          NaN   
                          2022-07-01 01:10:41+02:00 simulator 0.5                        13.61   
                          2022-07-01 02:10:32+02:00 simulator 0.5                        13.61   
                                                                                      wind_speed  \
event_start               belief_time               source    cumulative_probability               
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                            NaN   
                          2022-07-01 01:10:41+02:00 simulator 0.5                            NaN   
                          2022-07-01 02:10:32+02:00 simulator 0.5                           2.88   
                                                                                      cloud_cover  
event_start               belief_time               source    cumulative_probability               
2022-07-01 02:00:00+02:00 2022-06-30 15:10:30+02:00 simulator 0.5                            0.94  
                          2022-07-01 01:10:41+02:00 simulator 0.5                            0.94  
                          2022-07-01 02:10:32+02:00 simulator 0.5                            0.94