TurningPoints.date#

TurningPoints.date(endog)[source]#

Date the chronology of a series.

Candidates from the local-extremum test, thinned to alternate, then pruned for the duration rules; the contraction indicator is filled by walking the surviving turns, with the state before the first turn set to contraction when that turn is a trough, and the phase table computed over every completed phase.

Parameters:

endog (ArrayLike) – The series in levels (or logs); the rules act on the level, not on a cycle component.

Return type:

TurningPointsResult

Returns:

The TurningPointsResult.

Raises:

Example

>>> import numpy as np
>>> t = np.arange(120.0)
>>> res = TurningPoints().date(np.sin(2 * np.pi * t / 40))
>>> res.peaks, res.troughs, res.nobs
(array([10, 50, 90]), array([ 30,  70, 110]), 120)
>>> bool(res.contraction[11]) and not bool(res.contraction[31])
True
>>> TurningPoints().date(np.zeros(20)).phases
()
>>> TurningPoints().date(np.zeros(8))
Traceback (most recent call last):
    ...
cultivars.exceptions.SpecificationError: a series of 8 observations is too short ...