Test for float weights Kaplan Meier
Adding test for float weights for the Kaplan Meier fitter. Compares to simple example
@@ -485,6 +485,13 @@ class TestKaplanMeierFitter():
warnings.simplefilter("always")
kmf = KaplanMeierFitter().fit(T, E, weights=np.random.random(n))
assert True
+ def test_float_weights():
+ T = np.array([1,2,3,4,5])
+ W = np.array([2.1,0.9,0.9,0.9,0.9])
+ correct = np.array([1.0,0.632,0.474,0.316,0.158,0.0]).reshape((6,1))
+ kmf = ll.KaplanMeierFitter().fit(T,weights=W)
+ npt.assert_almost_equal(correct,kmf.survival_function_,decimal=3)
+
class TestNelsonAalenFitter():
