mix
survival.mix(curves, weights)Population mixture: weight several curves’ survival functions.
The mixture survival function is the weighted average sum(weight * curve.survival(t)), the population curve for a cohort made up of subgroups that each follow their own curve, for example responders and non-responders to a treatment. The cumulative hazard implied by that survival function has no closed-form inverse in general, so sampling from the result uses heormodel.survival.curve.numeric_inverse_cumulative_hazard.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| curves | Sequence[SurvivalCurve] |
At least two component curves. | required |
| weights | Sequence[float] |
Mixture weight for each curve, non-negative and summing to 1. | required |
Returns
| Name | Type | Description |
|---|---|---|
| SurvivalCurve | A new SurvivalCurve for the mixture. |
Example
from heormodel.survival import exponential, mix curve = mix([exponential(rate=0.1), exponential(rate=0.5)], [0.5, 0.5]) round(float(curve.survival(5.0)), 5) 0.34431