Numerical Calculus

differentiate, sliding_window_integration, trapezoidal_integration

Differentiation

indsl.ts_utils.numerical_calculus.differentiate(series: Series, granularity: str = '1h', time_unit: str = 'auto')

Differentiation

Differentiation (finite difference) using a second-order accurate numerical method (central difference). Boundary points are computed using a first-order accurate method.

Parameters
  • series – Time series.

  • granularity – Granularity. Current granularity for the chart on-screen (auto-given).

  • time_unit – Frequency. User defined granularity to potentially override unit of time. Accepts integer followed by time unit string (s|m|h|d). For example: ‘1s’, ‘5m’, ‘3h’ or ‘1d’.

Returns

First order derivative.

Return type

pandas.Series

Trapezoidal integration

indsl.ts_utils.numerical_calculus.trapezoidal_integration(series: Series, granularity: str = '1h', time_unit: str = 'auto')

Integration

Cumulative integration using trapezoidal rule with an optional user-defined time unit.

Parameters
  • series – Time series.

  • granularity – Granularity. Current granularity for the chart on-screen (auto-given).

  • time_unit – Frequency. User defined granularity to potentially override unit of time. Accepts integer followed by time unit string (s|m|h|d). For example: ‘1s’, ‘5m’, ‘3h’ or ‘1d’.

Returns

Cumulative integral.

Return type

pandas.Series

Sliding window integration

indsl.ts_utils.numerical_calculus.sliding_window_integration(series: Series, window_length: Timedelta = Timedelta('0 days 00:05:00'), integrand_rate: Timedelta = Timedelta('0 days 01:00:00')) Series

Sliding window integration

Siding window integration using trapezoidal rule.

Parameters
  • series – Time series.

  • window_length

    window_length the length of time the window. Defaults to ‘5 minute’. Valid time units are:

    • ‘W’, ‘D’, ‘T’, ‘S’, ‘L’, ‘U’, or ‘N’

    • ‘days’ or ‘day’

    • ‘hours’, ‘hour’, ‘hr’, or ‘h’

    • ‘minutes’, ‘minute’, ‘min’, or ‘m’

    • ‘seconds’, ‘second’, or ‘sec’

    • ‘milliseconds’, ‘millisecond’, ‘millis’, or ‘milli’

    • ‘microseconds’, ‘microsecond’, ‘micros’, or ‘micro’

    • ‘nanoseconds’, ‘nanosecond’, ‘nanos’, ‘nano’, or ‘ns’.

  • integrand_rate

    integrand_rate. if the integrands rate is per sec, per hour, per day. Defaults to ‘1 hour’. Valid time units are:

    • ‘W’, ‘D’, ‘T’, ‘S’, ‘L’, ‘U’, or ‘N’

    • ‘days’ or ‘day’

    • ‘hours’, ‘hour’, ‘hr’, or ‘h’

    • ‘minutes’, ‘minute’, ‘min’, or ‘m’

    • ‘seconds’, ‘second’, or ‘sec’

    • ‘milliseconds’, ‘millisecond’, ‘millis’, or ‘milli’

    • ‘microseconds’, ‘microsecond’, ‘micros’, or ‘micro’

    • ‘nanoseconds’, ‘nanosecond’, ‘nanos’, ‘nano’, or ‘ns’.

Returns

Time series

Return type

pandas.Series