cleverly.interventions.Piecewise#
- class cleverly.interventions.Piecewise(pieces: tuple[tuple[float, float, Shift | Scale], ...], closed: Literal['left', 'right'] = 'left', name: str = '')[source]#
A policy that applies a different shift or scale on each interval of the dose.
Hoffman, Salazar-Barreto, Williams, Rudolph and Díaz (2024, Example 5) shorten only the long surgeries. Each piece holds an uncapped
ShiftorScale, and the density ratio is Equation (3) of Díaz, Williams, Hoffman and Schenck (2023) summed over the pieces, with the derivative \(1 / c\) of each scaled piece’s inverse.Piecewise(((-inf, 60.0, Shift(0.0, None)), (60.0, inf, Shift(-15.0, None))))
- Parameters:
- pieces
tupleoftuple (lower, upper, map)per piece, wheremapisShift(delta, None)orScale(factor, None). The intervals do not overlap. A dose in no interval keeps its value, and the density ratio counts it as an identity piece.- closed{“left”, “right”}
Which end of every interval belongs to it.
- name
str The report label.
- pieces