Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute the time integral of a BeliefsDataFrame #73

Open
Flix6x opened this issue Sep 28, 2021 · 1 comment
Open

Compute the time integral of a BeliefsDataFrame #73

Flix6x opened this issue Sep 28, 2021 · 1 comment

Comments

@Flix6x
Copy link
Collaborator

Flix6x commented Sep 28, 2021

I often need to take the time integral of a BeliefsDataFrame, for example, when converting from a power flow to accumulated demand. It would be nice to be able to do this out of the box. Some sub-issues:

  • The sensor unit is no longer the correct unit for the integral time series.
  • The event resolution probably needs to be updated, too, maybe depending on the use case for taking the integration. For example, accumulated demand should get an event resolution of timedelta(0) (for instantaneous events).
  • We could decided to retain the original sensor or create a new sensor on the fly (I'm leaning towards the former).
  • Grouping by source is required.
  • Grouping by belief time is required, too. However, for some belief time of event B, its integral should be influenced by the most recent belief of event A (even if one with the same belief time is missing). So this requires some attention.
  • Taking the integral over probabilistic beliefs requires some probabilistic math, too, and is worth opening up a separate issue for.
@Flix6x
Copy link
Collaborator Author

Flix6x commented Jan 13, 2022

Proposed behaviour:

df = BeliefsDataFrame(some_timed_beliefs)

# The integrate method stands for taking the definite time integral with respect to the events
idf = df.integrate()

# The original sensor is retained
idf.sensor == df.sensor

# It follows that
idf.sensor.unit == df.sensor.unit
idf.sensor.event_resolution == df.sensor.event_resolution

# However, the unit and event resolution of the data have changed
idf.unit != df.sensor.unit
idf.event_resolution == timedelta(0)

Two notes:

  1. df.unit is a new BeliefsDataFrame property, next to df.sensor and df.event_resolution. We might want to use pint for unit conversion.
  2. I believe setting the event resolution to zero only makes sense for definite integrals, and not for indefinite integrals. For the latter case, we should retain the original event resolution, and make an assumption about what the event values describe. For example, if the event values describe mean values over sequential time intervals, we could take the assumption that the values within each interval are constant. Then it is possible to determine the indefinite integral, and we can report it's mean value in the original event resolution.

Finally, an example illustrating the belief timing sub-issue for (sequential) events A, B and C:

df (free-form representation)

belief_time    A     B     C
12:00          10          10
13:00          11    12      
14:00                      11
15:00          12
16:00                11

idf (free-form representation)

belief_time    A     B     C
12:00          10    10    20
13:00          11    23    33
14:00                      34
15:00          12    24    35
16:00                23    34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant