Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Kaplan-Meier snippet
n, k = len(te), 0
ts, ys = [], []
p = 1.0
for t, e in te:
if e: # whether the event was "observed" (converted) or not observed (may convert in the future)
p *= (n-1) / n
n -= 1
ys.append(100. * (1-p))
pyplot.plot(ts, ys, 'b')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment