Created
May 22, 2017 01:59
-
-
Save erikbern/3985e840a136949544a0971ed696a75c to your computer and use it in GitHub Desktop.
Kaplan-Meier snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
ts.append(t) | |
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