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 Shift or Scale, 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:
piecestuple of tuple

(lower, upper, map) per piece, where map is Shift(delta, None) or Scale(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.

namestr

The report label.

Methods#

Attributes#

Piecewise.closed: Literal['left', 'right'] = 'left'#
Piecewise.name: str = ''#
Piecewise.pieces: tuple[tuple[float, float, Shift | Scale], ...]#