Survival kaplanmeiercurve equals - CyrilB1531/lodestar GitHub Wiki

Home › Survival › Survival estimators

KaplanMeierCurve.Equals

Compares the steps and all three curves, element by element.

public bool Equals(KaplanMeierCurve other)

Parameters — other is the curve to compare against, or null.

Returns — true when the confidence level matches and the steps, estimates and both bounds hold the same values.

Example — the same curve, built twice.

using Lodestar.Survival;

SurvivalStep[] steps = [new(0.0, 4, 0, 0), new(1.0, 4, 1, 0)];
KaplanMeierCurve left = new(steps, [1.0, 0.75], [0.4, 0.3], [0.9, 0.8], 0.95);
KaplanMeierCurve right = new(
    [new(0.0, 4, 0, 0), new(1.0, 4, 1, 0)], [1.0, 0.75], [0.4, 0.3], [0.9, 0.8], 0.95);

bool same = left == right;  // => True

Remarks — SurvivalStep is a record of value types, so its own equality is already correct; what needed writing is the comparison of the arrays holding it. the equality rule has the rule.

Applies to — net10.0, netstandard2.0.

See also — KaplanMeierCurve.GetHashCode, KaplanMeierCurve.