/
test_nonparametric.py
601 lines (525 loc) · 43.1 KB
/
test_nonparametric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
from os.path import join, dirname
import numpy
from numpy.testing import assert_array_equal, assert_array_almost_equal
import pandas
import pytest
from sksurv.nonparametric import (
CensoringDistributionEstimator,
kaplan_meier_estimator,
nelson_aalen_estimator,
SurvivalFunctionEstimator)
from sksurv.util import Surv
CHANNING_FILE = join(dirname(__file__), 'data', 'channing.csv')
AIDS_CHILDREN_FILE = join(dirname(__file__), 'data', 'Lagakos_AIDS_children.csv')
AIDS_ADULTS_FILE = join(dirname(__file__), 'data', 'Lagakos_AIDS_adults.csv')
@pytest.fixture(params=[
'all_uncensored',
'all_censored',
'first_censored',
'last_censored',
'first_and_last_censored',
])
def simple_data_km(request):
time = [1, 2, 2, 3, 7, 6, 5, 5, 3, 9, 11, 13, 17, 13, 6, 23]
true_x = numpy.array([1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 23])
if request.param == 'all_uncensored':
event = numpy.repeat(True, len(time))
true_y = numpy.array([0.9375, 0.8125, 0.6875, 0.5625, 0.4375, 0.375, 0.3125, 0.25, 0.125, 0.0625, 0])
elif request.param == 'all_censored':
event = numpy.repeat(False, len(time))
true_y = numpy.ones(true_x.shape[0])
elif request.param == 'first_censored':
event = numpy.repeat(True, len(time))
event[0] = False
true_y = numpy.array([1, 0.866666666666667, 0.733333333333333, 0.6, 0.466666666666667, 0.4,
0.333333333333333, 0.266666666666667, 0.133333333333333, 0.0666666666666667, 0])
elif request.param == 'last_censored':
event = numpy.repeat(True, len(time))
event[-1] = False
true_y = numpy.array([0.9375, 0.8125, 0.6875, 0.5625, 0.4375, 0.375, 0.3125, 0.25, 0.125, 0.0625, 0.0625])
elif request.param == 'first_and_last_censored':
event = numpy.repeat(True, len(time))
event[0] = False
event[-1] = False
true_y = numpy.array(
[1, 0.866666666666667, 0.733333333333333, 0.6, 0.466666666666667, 0.4,
0.333333333333333, 0.266666666666667, 0.133333333333333, 0.0666666666666667, 0.0666666666666667])
else:
assert False, 'should not be reached'
return time, event, true_x, true_y
@pytest.fixture(params=['all_uncensored', 'first_censored', 'last_censored', 'first_and_last_censored'])
def simple_data_na(request):
time = [1, 2, 2, 3, 7, 6, 5, 5, 3, 9, 11, 13, 17, 13, 6, 23]
true_x = numpy.array([1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 23])
if request.param == 'all_uncensored':
event = numpy.repeat(True, len(time))
true_y = numpy.array([0.0625, 0.195833333333333, 0.349679487179487, 0.531497668997669, 0.753719891219891,
0.896577034077034, 1.0632437007437, 1.2632437007437, 1.7632437007437, 2.2632437007437,
3.2632437007437])
elif request.param == 'first_censored':
event = numpy.repeat(True, len(time))
event[0] = False
true_y = numpy.array([0, 0.133333333333333, 0.287179487179487, 0.468997668997669, 0.691219891219891,
0.834077034077034, 1.0007437007437, 1.2007437007437, 1.7007437007437, 2.2007437007437,
3.2007437007437])
elif request.param == 'last_censored':
event = numpy.repeat(True, len(time))
event[-1] = False
true_y = numpy.array([0.0625, 0.195833333333333, 0.349679487179487, 0.531497668997669, 0.753719891219891,
0.896577034077034, 1.0632437007437, 1.2632437007437, 1.7632437007437, 2.2632437007437,
2.2632437007437])
elif request.param == 'first_and_last_censored':
event = numpy.repeat(True, len(time))
event[0] = False
event[-1] = False
true_y = numpy.array(
[0, 0.133333333333333, 0.287179487179487, 0.468997668997669, 0.691219891219891, 0.834077034077034,
1.0007437007437, 1.2007437007437, 1.7007437007437, 2.2007437007437, 2.2007437007437])
else:
assert False, 'should not be reached'
return time, event, true_x, true_y
@pytest.fixture
def make_channing():
def _make_channing(sex):
data = pandas.read_csv(CHANNING_FILE).query("entry < exit and sex == @sex")
time_enter_m = data.loc[:, "entry"].values
time_exit_m = data.loc[:, "exit"].values
event_m = data.loc[:, "cens"].values == 1
return time_enter_m, time_exit_m, event_m
return _make_channing
@pytest.fixture
def make_aids():
def _make_aids(kind):
if kind == 'children':
f = AIDS_CHILDREN_FILE
elif kind == 'adults':
f = AIDS_ADULTS_FILE
else:
raise ValueError('unknown kind {!r}'.format(kind))
data = pandas.read_csv(f, comment="#")
event = numpy.repeat(True, data.shape[0])
time_enter = 8 - data["INF"]
time_exit = data["DIAG"]
return event, time_enter, time_exit
return _make_aids
class TestKaplanMeier(object):
@staticmethod
def test_simple(simple_data_km):
time, event, true_x, true_y = simple_data_km
x, y = kaplan_meier_estimator(event, time)
assert_array_equal(x, true_x)
assert_array_almost_equal(y, true_y)
ys = Surv.from_arrays(event, time)
est = SurvivalFunctionEstimator().fit(ys)
assert_array_equal(est.unique_time_[1:], true_x)
assert_array_almost_equal(est.prob_[1:], true_y)
prob = est.predict_proba(true_x)
assert_array_almost_equal(prob, true_y)
@staticmethod
def test_truncated_enter_larger_exit_error():
rnd = numpy.random.RandomState(2016)
time_exit = rnd.uniform(1, 100, size=25)
time_enter = time_exit + 1
event = rnd.binomial(1, 0.6, size=25).astype(bool)
with pytest.raises(ValueError, match="exit time must be larger start time for all samples"):
kaplan_meier_estimator(event, time_exit, time_enter)
@staticmethod
def test_whas500(make_whas500):
whas500 = make_whas500(with_mean=False, with_std=False)
time = whas500.y['lenfol']
event = whas500.y['fstat']
x, y = kaplan_meier_estimator(event, time)
true_x = numpy.array(
[1, 2, 3, 4, 5, 6, 7, 10, 11, 14, 16, 17, 18, 19, 20, 22, 26, 31, 32, 33, 34, 37, 42, 46, 49, 52, 53, 55,
57, 60, 61, 62, 64, 69, 76, 81, 83, 88, 91, 93, 95, 97, 100, 101, 108, 109, 113, 116, 117, 118, 129, 132,
134, 135, 137, 140, 143, 145, 146, 151, 166, 169, 187, 192, 197, 200, 226, 233, 235, 259, 269, 274, 287,
289, 295, 297, 312, 313, 321, 328, 343, 345, 354, 358, 359, 363, 368, 371, 373, 376, 382, 385, 386, 390,
392, 397, 398, 399, 400, 403, 405, 406, 407, 408, 411, 412, 416, 418, 419, 421, 422, 424, 426, 427, 433,
437, 440, 442, 445, 446, 449, 450, 451, 452, 457, 458, 459, 465, 466, 467, 473, 475, 478, 479, 480, 486,
497, 506, 507, 510, 511, 516, 519, 521, 522, 523, 524, 529, 530, 532, 535, 537, 542, 544, 550, 551, 552,
554, 559, 562, 568, 570, 573, 578, 587, 589, 606, 609, 612, 614, 626, 631, 632, 644, 646, 649, 654, 659,
662, 670, 673, 675, 704, 714, 718, 725, 849, 865, 903, 905, 920, 936, 953, 1048, 1054, 1065, 1096, 1098,
1102, 1103, 1105, 1106, 1107, 1108, 1109, 1114, 1117, 1121, 1123, 1125, 1126, 1136, 1140, 1150, 1151, 1152,
1157, 1159, 1160, 1161, 1162, 1163, 1165, 1169, 1170, 1174, 1178, 1182, 1187, 1189, 1190, 1191, 1196, 1199,
1200, 1203, 1207, 1211, 1217, 1223, 1224, 1231, 1232, 1233, 1234, 1235, 1244, 1245, 1248, 1251, 1253, 1256,
1257, 1262, 1265, 1266, 1272, 1273, 1274, 1277, 1279, 1280, 1290, 1295, 1298, 1302, 1308, 1314, 1317, 1319,
1320, 1325, 1329, 1332, 1333, 1336, 1338, 1346, 1347, 1353, 1359, 1363, 1365, 1366, 1374, 1377, 1378, 1381,
1384, 1385, 1388, 1390, 1400, 1408, 1409, 1420, 1430, 1433, 1438, 1444, 1449, 1451, 1454, 1456, 1458, 1496,
1506, 1527, 1536, 1548, 1553, 1576, 1577, 1579, 1624, 1627, 1671, 1831, 1836, 1847, 1854, 1858, 1863, 1880,
1883, 1885, 1887, 1889, 1893, 1899, 1904, 1914, 1919, 1920, 1923, 1926, 1931, 1933, 1934, 1936, 1939, 1940,
1941, 1942, 1954, 1955, 1964, 1969, 1976, 1977, 1979, 1993, 1994, 2006, 2009, 2025, 2032, 2048, 2057, 2061,
2064, 2065, 2066, 2083, 2084, 2086, 2100, 2108, 2113, 2114, 2118, 2122, 2123, 2125, 2126, 2131, 2132, 2139,
2145, 2146, 2151, 2152, 2156, 2160, 2166, 2168, 2172, 2173, 2175, 2178, 2190, 2192, 2350, 2353, 2358])
assert_array_equal(x.astype(numpy.int_), true_x)
true_y = numpy.array(
[0.984, 0.968, 0.962, 0.958, 0.954, 0.944, 0.932, 0.926, 0.918, 0.914, 0.912, 0.908, 0.902, 0.896, 0.892,
0.888, 0.886, 0.884, 0.88, 0.874, 0.872, 0.87, 0.868, 0.866, 0.864, 0.862, 0.86, 0.858, 0.854, 0.852, 0.85,
0.848, 0.844, 0.84, 0.838, 0.836, 0.834, 0.832, 0.83, 0.828, 0.826, 0.824, 0.822, 0.82, 0.818, 0.816,
0.814, 0.812, 0.81, 0.808, 0.806, 0.804, 0.802, 0.8, 0.798, 0.794, 0.792, 0.79, 0.788, 0.786, 0.784, 0.78,
0.776, 0.774, 0.772, 0.77, 0.768, 0.766, 0.764, 0.76, 0.758, 0.756, 0.754, 0.752, 0.75, 0.746, 0.744,
0.742, 0.74, 0.738, 0.736, 0.734, 0.732, 0.73, 0.726, 0.724, 0.724, 0.724, 0.724, 0.724, 0.721960563380282,
0.719921126760564, 0.719921126760564, 0.719921126760564, 0.717864209255533, 0.715807291750503,
0.715807291750503, 0.715807291750503, 0.715807291750503, 0.715807291750503, 0.713714287973455,
0.711621284196407, 0.711621284196407, 0.711621284196407, 0.711621284196407, 0.711621284196407,
0.711621284196407, 0.711621284196407, 0.709484283342964, 0.709484283342964, 0.70734082629359,
0.70734082629359, 0.70734082629359, 0.70734082629359, 0.70734082629359, 0.70734082629359, 0.70734082629359,
0.705150916614662, 0.705150916614662, 0.702926465773606, 0.702926465773606, 0.702926465773606,
0.702926465773606, 0.702926465773606, 0.702926465773606, 0.702926465773606, 0.702926465773606,
0.700621788836644, 0.700621788836644, 0.69830950570517, 0.695997222573696, 0.695997222573696,
0.695997222573696, 0.693669472665422, 0.693669472665422, 0.693669472665422, 0.691325994717228,
0.691325994717228, 0.691325994717228, 0.691325994717228, 0.691325994717228, 0.691325994717228,
0.691325994717228, 0.691325994717228, 0.691325994717228, 0.691325994717228, 0.691325994717228,
0.691325994717228, 0.688865759860583, 0.688865759860583, 0.686387825472596, 0.683900913061463,
0.68141400065033, 0.68141400065033, 0.68141400065033, 0.68141400065033, 0.678871411095665,
0.678871411095665, 0.676319262933651, 0.673767114771638, 0.673767114771638, 0.673767114771638,
0.673767114771638, 0.673767114771638, 0.673767114771638, 0.673767114771638, 0.673767114771638,
0.673767114771638, 0.671114488335529, 0.66846186189942, 0.66846186189942, 0.66846186189942,
0.665788014451822, 0.663114167004225, 0.660440319556627, 0.657766472109029, 0.655092624661431,
0.655092624661431, 0.655092624661431, 0.652396770238956, 0.649700915816481, 0.649700915816481,
0.646993828667246, 0.644286741518011, 0.641579654368776, 0.641579654368776, 0.638861096511281,
0.636142538653786, 0.633423980796291, 0.630705422938796, 0.627986865081301, 0.625268307223807,
0.622549749366312, 0.619831191508817, 0.617112633651322, 0.614394075793827, 0.611675517936333,
0.611675517936333, 0.611675517936333, 0.611675517936333, 0.611675517936333, 0.611675517936333,
0.611675517936333, 0.611675517936333, 0.611675517936333, 0.611675517936333, 0.611675517936333,
0.611675517936333, 0.611675517936333, 0.611675517936333, 0.611675517936333, 0.608734770253946,
0.608734770253946, 0.608734770253946, 0.608734770253946, 0.605721231787343, 0.605721231787343,
0.602692625628406, 0.602692625628406, 0.602692625628406, 0.602692625628406, 0.602692625628406,
0.599601894214927, 0.599601894214927, 0.599601894214927, 0.596478967682557, 0.596478967682557,
0.596478967682557, 0.596478967682557, 0.596478967682557, 0.596478967682557, 0.596478967682557,
0.596478967682557, 0.596478967682557, 0.593183503772709, 0.593183503772709, 0.593183503772709,
0.593183503772709, 0.589832184542355, 0.589832184542355, 0.589832184542355, 0.589832184542355,
0.586422749949625, 0.582973204361686, 0.582973204361686, 0.582973204361686, 0.582973204361686,
0.582973204361686, 0.582973204361686, 0.582973204361686, 0.582973204361686, 0.582973204361686,
0.582973204361686, 0.582973204361686, 0.582973204361686, 0.582973204361686, 0.582973204361686,
0.582973204361686, 0.582973204361686, 0.582973204361686, 0.579112454663926, 0.579112454663926,
0.579112454663926, 0.579112454663926, 0.579112454663926, 0.579112454663926, 0.579112454663926,
0.579112454663926, 0.575034197940941, 0.575034197940941, 0.575034197940941, 0.575034197940941,
0.575034197940941, 0.575034197940941, 0.575034197940941, 0.575034197940941, 0.575034197940941,
0.575034197940941, 0.575034197940941, 0.575034197940941, 0.570506369610697, 0.570506369610697,
0.570506369610697, 0.570506369610697, 0.570506369610697, 0.561153806174456, 0.561153806174456,
0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456,
0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456,
0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456, 0.561153806174456,
0.561153806174456, 0.561153806174456, 0.561153806174456, 0.555542268112711, 0.549930730050967,
0.544319191989222, 0.538707653927478, 0.533096115865733, 0.527484577803989, 0.521873039742244,
0.5162615016805, 0.510649963618755, 0.505038425557011, 0.499426887495266, 0.493815349433521,
0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521,
0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521,
0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521, 0.493815349433521,
0.493815349433521, 0.493815349433521, 0.493815349433521, 0.486444971083767, 0.486444971083767,
0.486444971083767, 0.486444971083767, 0.486444971083767, 0.486444971083767, 0.486444971083767,
0.486444971083767, 0.486444971083767, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052, 0.477910848784052,
0.477910848784052, 0.438084944718714, 0.438084944718714, 0.438084944718714, 0.438084944718714,
0.438084944718714, 0.438084944718714, 0.438084944718714, 0.438084944718714, 0.438084944718714,
0.292056629812476, 0.146028314906238, 0])
assert_array_almost_equal(y, true_y)
@staticmethod
def test_truncated_male(make_channing):
time_enter_m, time_exit_m, event_m = make_channing('Male')
x, y = kaplan_meier_estimator(event_m, time_exit_m, time_enter_m)
x_true = numpy.array(
[751, 759, 777, 781, 782, 806, 817, 820, 821, 823, 830, 835, 836, 837, 843, 846, 847, 852, 853, 854, 856,
863, 865, 866, 869, 871, 872, 875, 876, 878, 879, 883, 885, 886, 890, 891, 893, 894, 895, 898, 900, 906,
907, 909, 911, 914, 915, 919, 921, 923, 925, 926, 927, 932, 936, 938, 940, 943, 945, 946, 948, 951, 953,
955, 956, 957, 959, 960, 962, 964, 966, 967, 969, 970, 971, 972, 973, 977, 978, 981, 982, 983, 984, 985,
988, 989, 993, 996, 998, 1001, 1002, 1005, 1006, 1007, 1009, 1010, 1012, 1013, 1015, 1016, 1018, 1020,
1021, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1036, 1039, 1041, 1043, 1044, 1045, 1046, 1047, 1051, 1053,
1055, 1058, 1059, 1060, 1063, 1064, 1070, 1073, 1080, 1085, 1093, 1094, 1106, 1107, 1118, 1128, 1139,
1153])
assert_array_equal(x, x_true)
assert_array_equal(y[:3], numpy.array([1., 1., .5]))
assert (y[3:] == 0).all()
@staticmethod
def test_truncated_male_older_68(make_channing):
time_enter_m, time_exit_m, event_m = make_channing('Male')
x, y = kaplan_meier_estimator(event_m, time_exit_m, time_enter_m, time_min=68 * 12)
x_true = numpy.array(
[817, 820, 821, 823, 830, 835, 836, 837, 843, 846, 847, 852, 853, 854, 856,
863, 865, 866, 869, 871, 872, 875, 876, 878, 879, 883, 885, 886, 890, 891, 893, 894, 895, 898, 900, 906,
907, 909, 911, 914, 915, 919, 921, 923, 925, 926, 927, 932, 936, 938, 940, 943, 945, 946, 948, 951, 953,
955, 956, 957, 959, 960, 962, 964, 966, 967, 969, 970, 971, 972, 973, 977, 978, 981, 982, 983, 984, 985,
988, 989, 993, 996, 998, 1001, 1002, 1005, 1006, 1007, 1009, 1010, 1012, 1013, 1015, 1016, 1018, 1020,
1021, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1036, 1039, 1041, 1043, 1044, 1045, 1046, 1047, 1051, 1053,
1055, 1058, 1059, 1060, 1063, 1064, 1070, 1073, 1080, 1085, 1093, 1094, 1106, 1107, 1118, 1128, 1139,
1153])
assert_array_equal(x, x_true)
assert (y[:18] == 1).all()
y_true = numpy.array(
[0.958333, 0.958333, 0.920000, 0.920000, 0.884615, 0.884615, 0.884615, 0.884615, 0.884615, 0.884615,
0.884615, 0.884615, 0.858597, 0.833344, 0.833344, 0.808092, 0.808092, 0.808092, 0.784324, 0.761256,
0.738187, 0.738187, 0.738187, 0.738187, 0.738187, 0.738187, 0.738187, 0.738187, 0.718236, 0.698285,
0.698285, 0.698285, 0.698285, 0.698285, 0.678889, 0.678889, 0.659492, 0.659492, 0.659492, 0.659492,
0.659492, 0.641173, 0.641173, 0.641173, 0.641173, 0.641173, 0.624300, 0.624300, 0.608692, 0.608692,
0.593085, 0.593085, 0.593085, 0.593085, 0.593085, 0.593085, 0.593085, 0.577877, 0.577877, 0.563060,
0.563060, 0.548623, 0.519748, 0.519748, 0.504898, 0.504898, 0.504898, 0.504898, 0.504898, 0.504898,
0.488611, 0.488611, 0.458073, 0.458073, 0.458073, 0.458073, 0.458073, 0.458073, 0.458073, 0.441713,
0.441713, 0.424724, 0.424724, 0.407735, 0.390746, 0.372139, 0.354418, 0.354418, 0.354418, 0.338308,
0.321393, 0.321393, 0.321393, 0.321393, 0.321393, 0.303538, 0.285682, 0.285682, 0.266637, 0.247591,
0.247591, 0.247591, 0.247591, 0.247591, 0.225083, 0.202575, 0.202575, 0.151931, 0.151931, 0.151931,
0.151931, 0.101287, 0.050644, 0.050644])
assert_array_almost_equal(y[18:], y_true)
@staticmethod
def test_truncated_female(make_channing):
time_enter_f, time_exit_f, event_f = make_channing('Female')
x, y = kaplan_meier_estimator(event_f, time_exit_f, time_enter_f)
x_true = numpy.array(
[733, 746, 748, 760, 762, 768, 769, 772, 775, 777, 783, 792, 794, 795, 796, 797, 798, 799, 802, 804, 805,
807, 808, 809, 810, 811, 812, 813, 814, 815, 818, 819, 820, 821, 822, 823, 824, 825, 827, 828, 829, 830,
831, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852,
854, 855, 856, 857, 858, 859, 860, 861, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875,
876, 877, 878, 881, 882, 883, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899,
900, 901, 902, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921,
922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 938, 939, 940, 941, 942, 943,
944, 945, 946, 947, 948, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965,
966, 967, 968, 969, 970, 971, 972, 973, 975, 976, 977, 978, 979, 981, 982, 983, 984, 985, 986, 987, 988,
989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1026,
1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044,
1047, 1049, 1050, 1051, 1053, 1054, 1055, 1056, 1057, 1059, 1061, 1062, 1063, 1064, 1065, 1068, 1070, 1071,
1072, 1073, 1074, 1080, 1083, 1084, 1085, 1086, 1088, 1089, 1091, 1093, 1096, 1097, 1102, 1105, 1109, 1114,
1115, 1119, 1122, 1131, 1132, 1134, 1140, 1142, 1147, 1152, 1172, 1186, 1192, 1200, 1207])
assert_array_equal(x, x_true)
assert (y[:19] == 1).all()
y_true = numpy.array(
[0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.952381,
0.952381, 0.952381, 0.952381, 0.952381, 0.952381, 0.927318, 0.927318, 0.927318, 0.927318, 0.927318,
0.927318, 0.927318, 0.907588, 0.907588, 0.907588, 0.907588, 0.907588, 0.907588, 0.907588, 0.907588,
0.907588, 0.892710, 0.892710, 0.892710, 0.892710, 0.892710, 0.879386, 0.879386, 0.879386, 0.879386,
0.879386, 0.879386, 0.879386, 0.879386, 0.879386, 0.879386, 0.879386, 0.879386, 0.879386, 0.879386,
0.879386, 0.869930, 0.869930, 0.869930, 0.869930, 0.869930, 0.869930, 0.861317, 0.861317, 0.861317,
0.861317, 0.861317, 0.853267, 0.853267, 0.853267, 0.853267, 0.853267, 0.853267, 0.853267, 0.853267,
0.846097, 0.839161, 0.839161, 0.839161, 0.839161, 0.839161, 0.839161, 0.839161, 0.839161, 0.839161,
0.839161, 0.833167, 0.833167, 0.827258, 0.827258, 0.827258, 0.827258, 0.821669, 0.821669, 0.821669,
0.810786, 0.810786, 0.810786, 0.799829, 0.799829, 0.799829, 0.794532, 0.794532, 0.794532, 0.794532,
0.789236, 0.789236, 0.789236, 0.789236, 0.784077, 0.784077, 0.784077, 0.784077, 0.779115, 0.779115,
0.779115, 0.774275, 0.774275, 0.769375, 0.769375, 0.764536, 0.759697, 0.754858, 0.754858, 0.750199,
0.750199, 0.745707, 0.745707, 0.745707, 0.741103, 0.736529, 0.736529, 0.736529, 0.727708, 0.727708,
0.727708, 0.727708, 0.723298, 0.723298, 0.723298, 0.723298, 0.723298, 0.718805, 0.718805, 0.718805,
0.718805, 0.718805, 0.714368, 0.714368, 0.714368, 0.714368, 0.709847, 0.709847, 0.709847, 0.705296,
0.705296, 0.705296, 0.696589, 0.692235, 0.692235, 0.692235, 0.692235, 0.687854, 0.683473, 0.683473,
0.679035, 0.679035, 0.679035, 0.670216, 0.665778, 0.665778, 0.665778, 0.661249, 0.661249, 0.661249,
0.656657, 0.638028, 0.633405, 0.628815, 0.628815, 0.619567, 0.610180, 0.596099, 0.596099, 0.591330,
0.586523, 0.581715, 0.576867, 0.576867, 0.572020, 0.567213, 0.562406, 0.552625, 0.552625, 0.552625,
0.552625, 0.547646, 0.542528, 0.532095, 0.526878, 0.521610, 0.516287, 0.516287, 0.510852, 0.499983,
0.489114, 0.483427, 0.477602, 0.477602, 0.465810, 0.459838, 0.459838, 0.454017, 0.454017, 0.448196,
0.442299, 0.442299, 0.442299, 0.436069, 0.436069, 0.436069, 0.436069, 0.436069, 0.436069, 0.436069,
0.410035, 0.390815, 0.390815, 0.384301, 0.377675, 0.370931, 0.370931, 0.370931, 0.370931, 0.370931,
0.370931, 0.370931, 0.355476, 0.355476, 0.355476, 0.355476, 0.355476, 0.347012, 0.338337, 0.338337,
0.320530, 0.311867, 0.311867, 0.302956, 0.294046, 0.284857, 0.284857, 0.275362, 0.265866, 0.246876,
0.237001, 0.237001, 0.226696, 0.226696, 0.215901, 0.215901, 0.205620, 0.205620, 0.205620, 0.205620,
0.205620, 0.191912, 0.191912, 0.177150, 0.162387, 0.147625, 0.147625, 0.147625, 0.132862, 0.132862,
0.116255, 0.099647, 0.099647, 0.074735, 0.024912, 0.024912])
assert_array_almost_equal(y[19:], y_true)
@staticmethod
def test_truncated_female_older_68(make_channing):
time_enter_f, time_exit_f, event_f = make_channing('Female')
x, y = kaplan_meier_estimator(event_f, time_exit_f, time_enter_f, time_min=68 * 12)
x_true = numpy.array(
[818, 819, 820, 821, 822, 823, 824, 825, 827, 828, 829, 830,
831, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852,
854, 855, 856, 857, 858, 859, 860, 861, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875,
876, 877, 878, 881, 882, 883, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899,
900, 901, 902, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921,
922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 938, 939, 940, 941, 942, 943,
944, 945, 946, 947, 948, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965,
966, 967, 968, 969, 970, 971, 972, 973, 975, 976, 977, 978, 979, 981, 982, 983, 984, 985, 986, 987, 988,
989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1026,
1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044,
1047, 1049, 1050, 1051, 1053, 1054, 1055, 1056, 1057, 1059, 1061, 1062, 1063, 1064, 1065, 1068, 1070, 1071,
1072, 1073, 1074, 1080, 1083, 1084, 1085, 1086, 1088, 1089, 1091, 1093, 1096, 1097, 1102, 1105, 1109, 1114,
1115, 1119, 1122, 1131, 1132, 1134, 1140, 1142, 1147, 1152, 1172, 1186, 1192, 1200, 1207])
assert_array_equal(x, x_true)
y_true = numpy.array(
[1, 1, 1, 1, 0.973684, 0.973684, 0.973684, 0.973684, 0.973684, 0.973684, 0.973684, 0.952968, 0.952968,
0.952968, 0.952968, 0.952968, 0.952968, 0.952968, 0.952968, 0.952968, 0.937345, 0.937345, 0.937345,
0.937345, 0.937345, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355,
0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.923355, 0.913426, 0.913426, 0.913426,
0.913426, 0.913426, 0.913426, 0.904383, 0.904383, 0.904383, 0.904383, 0.904383, 0.895930, 0.895930,
0.895930, 0.895930, 0.895930, 0.895930, 0.895930, 0.895930, 0.888402, 0.881120, 0.881120, 0.881120,
0.881120, 0.881120, 0.881120, 0.881120, 0.881120, 0.881120, 0.881120, 0.874826, 0.874826, 0.868621,
0.868621, 0.868621, 0.868621, 0.862752, 0.862752, 0.862752, 0.851325, 0.851325, 0.851325, 0.839821,
0.839821, 0.839821, 0.834259, 0.834259, 0.834259, 0.834259, 0.828697, 0.828697, 0.828697, 0.828697,
0.823281, 0.823281, 0.823281, 0.823281, 0.818070, 0.818070, 0.818070, 0.812989, 0.812989, 0.807844,
0.807844, 0.802763, 0.797682, 0.792601, 0.792601, 0.787709, 0.787709, 0.782992, 0.782992, 0.782992,
0.778159, 0.773355, 0.773355, 0.773355, 0.764093, 0.764093, 0.764093, 0.764093, 0.759463, 0.759463,
0.759463, 0.759463, 0.759463, 0.754745, 0.754745, 0.754745, 0.754745, 0.754745, 0.750086, 0.750086,
0.750086, 0.750086, 0.745339, 0.745339, 0.745339, 0.740561, 0.740561, 0.740561, 0.731419, 0.726847,
0.726847, 0.726847, 0.726847, 0.722247, 0.717647, 0.717647, 0.712987, 0.712987, 0.712987, 0.703727,
0.699067, 0.699067, 0.699067, 0.694311, 0.694311, 0.694311, 0.689489, 0.669929, 0.665075, 0.660255,
0.660255, 0.650546, 0.640689, 0.625904, 0.625904, 0.620897, 0.615849, 0.610801, 0.605711, 0.605711,
0.600621, 0.595574, 0.590526, 0.580256, 0.580256, 0.580256, 0.580256, 0.575029, 0.569655, 0.558700,
0.553222, 0.547690, 0.542101, 0.542101, 0.536395, 0.524982, 0.513570, 0.507598, 0.501482, 0.501482,
0.489100, 0.482830, 0.482830, 0.476718, 0.476718, 0.470606, 0.464414, 0.464414, 0.464414, 0.457873,
0.457873, 0.457873, 0.457873, 0.457873, 0.457873, 0.457873, 0.430537, 0.410356, 0.410356, 0.403516,
0.396559, 0.389478, 0.389478, 0.389478, 0.389478, 0.389478, 0.389478, 0.389478, 0.373250, 0.373250,
0.373250, 0.373250, 0.373250, 0.364363, 0.355254, 0.355254, 0.336556, 0.327460, 0.327460, 0.318104,
0.308748, 0.299100, 0.299100, 0.289130, 0.279160, 0.259220, 0.248851, 0.248851, 0.238031, 0.238031,
0.226696, 0.226696, 0.215901, 0.215901, 0.215901, 0.215901, 0.215901, 0.201508, 0.201508, 0.186007,
0.170507, 0.155006, 0.155006, 0.155006, 0.139506, 0.139506, 0.122067, 0.104629, 0.104629, 0.078472,
0.026157, 0.026157])
assert_array_almost_equal(y, y_true)
@staticmethod
def test_right_truncated_children(make_aids):
event, time_enter, time_exit = make_aids('children')
x, y = kaplan_meier_estimator(event, -time_exit.values, -time_enter.values)
true_x = numpy.array(
[0.25, 0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00, 3.25, 3.50, 3.75, 4.00, 4.25, 4.50,
5, 5.25, 5.50, 5.75, 6.50, 7])
true_y = numpy.array(
[0, 0.02, 0.09, 0.16, 0.22, 0.25, 0.30, 0.35, 0.35, 0.39, 0.43, 0.46, 0.52, 0.56, 0.61, 0.61, 0.61, 0.67,
0.67, 0.67, 0.67, 1.00, 1.00, 1.00])
assert_array_almost_equal(-x[::-1], true_x, 2)
assert_array_almost_equal(y[::-1], true_y, 2)
@staticmethod
def test_right_truncated_adults(make_aids):
event, time_enter, time_exit = make_aids('adults')
x, y = kaplan_meier_estimator(event, -time_exit.values, -time_enter.values)
true_x = numpy.array(
[0.25, 0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00, 3.25, 3.50, 3.75,
4.00, 4.25, 4.50, 4.75, 5.00, 5.25, 5.50, 5.75, 6.00, 6.25, 6.50, 6.75, 7, 7.25, 7.75, 8])
true_y = numpy.array(
[0, 0.003, 0.004, 0.01, 0.02, 0.03, 0.05, 0.06, 0.07, 0.09, 0.11, 0.13, 0.16, 0.18, 0.20,
0.21, 0.25, 0.29, 0.31, 0.34, 0.40, 0.49, 0.54, 0.58, 0.61, 0.64, 0.73, 0.8, 0.8, 1, 1])
assert_array_almost_equal(-x[::-1], true_x, 2)
assert_array_almost_equal(y[::-1], true_y, 2)
@staticmethod
def test_censoring_distribution():
y = Surv.from_arrays(numpy.array([1, 0, 0, 1, 0, 1, 0, 1, 1, 0], dtype=bool),
numpy.array([1, 2, 3, 3, 3, 4, 5, 5, 6, 7]))
cens = CensoringDistributionEstimator().fit(y)
probs = cens.predict_proba(numpy.arange(1, 8))
expected = numpy.array([1.0, 0.8888889, 0.6349206, 0.6349206, 0.4232804, 0.4232804, 0.0000000])
assert_array_almost_equal(expected, probs)
@staticmethod
def test_truncated_reverse_error():
rnd = numpy.random.RandomState(2016)
time_exit = rnd.uniform(1, 100, size=25)
time_enter = time_exit + 1
event = rnd.binomial(1, 0.6, size=25).astype(bool)
with pytest.raises(ValueError,
match="The censoring distribution cannot be estimated from left truncated data"):
kaplan_meier_estimator(event, time_exit, time_enter, reverse=True)
class TestNelsonAalen(object):
@staticmethod
def test_simple(simple_data_na):
time, event, true_x, true_y = simple_data_na
x, y = nelson_aalen_estimator(event, time)
assert_array_equal(x, true_x)
assert_array_almost_equal(y, true_y)
@staticmethod
def test_whas500(make_whas500):
whas500 = make_whas500(with_mean=False, with_std=False)
time = whas500.y['lenfol']
event = whas500.y['fstat']
x, y = nelson_aalen_estimator(event, time)
true_x = numpy.array(
[1, 2, 3, 4, 5, 6, 7, 10, 11, 14, 16, 17, 18, 19, 20, 22, 26, 31, 32, 33, 34, 37, 42, 46, 49, 52, 53, 55,
57, 60, 61, 62, 64, 69, 76, 81, 83, 88, 91, 93, 95, 97, 100, 101, 108, 109, 113, 116, 117, 118, 129, 132,
134, 135, 137, 140, 143, 145, 146, 151, 166, 169, 187, 192, 197, 200, 226, 233, 235, 259, 269, 274, 287,
289, 295, 297, 312, 313, 321, 328, 343, 345, 354, 358, 359, 363, 368, 371, 373, 376, 382, 385, 386, 390,
392, 397, 398, 399, 400, 403, 405, 406, 407, 408, 411, 412, 416, 418, 419, 421, 422, 424, 426, 427, 433,
437, 440, 442, 445, 446, 449, 450, 451, 452, 457, 458, 459, 465, 466, 467, 473, 475, 478, 479, 480, 486,
497, 506, 507, 510, 511, 516, 519, 521, 522, 523, 524, 529, 530, 532, 535, 537, 542, 544, 550, 551, 552,
554, 559, 562, 568, 570, 573, 578, 587, 589, 606, 609, 612, 614, 626, 631, 632, 644, 646, 649, 654, 659,
662, 670, 673, 675, 704, 714, 718, 725, 849, 865, 903, 905, 920, 936, 953, 1048, 1054, 1065, 1096, 1098,
1102, 1103, 1105, 1106, 1107, 1108, 1109, 1114, 1117, 1121, 1123, 1125, 1126, 1136, 1140, 1150, 1151, 1152,
1157, 1159, 1160, 1161, 1162, 1163, 1165, 1169, 1170, 1174, 1178, 1182, 1187, 1189, 1190, 1191, 1196, 1199,
1200, 1203, 1207, 1211, 1217, 1223, 1224, 1231, 1232, 1233, 1234, 1235, 1244, 1245, 1248, 1251, 1253, 1256,
1257, 1262, 1265, 1266, 1272, 1273, 1274, 1277, 1279, 1280, 1290, 1295, 1298, 1302, 1308, 1314, 1317, 1319,
1320, 1325, 1329, 1332, 1333, 1336, 1338, 1346, 1347, 1353, 1359, 1363, 1365, 1366, 1374, 1377, 1378, 1381,
1384, 1385, 1388, 1390, 1400, 1408, 1409, 1420, 1430, 1433, 1438, 1444, 1449, 1451, 1454, 1456, 1458, 1496,
1506, 1527, 1536, 1548, 1553, 1576, 1577, 1579, 1624, 1627, 1671, 1831, 1836, 1847, 1854, 1858, 1863, 1880,
1883, 1885, 1887, 1889, 1893, 1899, 1904, 1914, 1919, 1920, 1923, 1926, 1931, 1933, 1934, 1936, 1939, 1940,
1941, 1942, 1954, 1955, 1964, 1969, 1976, 1977, 1979, 1993, 1994, 2006, 2009, 2025, 2032, 2048, 2057, 2061,
2064, 2065, 2066, 2083, 2084, 2086, 2100, 2108, 2113, 2114, 2118, 2122, 2123, 2125, 2126, 2131, 2132, 2139,
2145, 2146, 2151, 2152, 2156, 2160, 2166, 2168, 2172, 2173, 2175, 2178, 2190, 2192, 2350, 2353, 2358])
assert_array_equal(x.astype(numpy.int_), true_x)
true_y = numpy.array(
[0.016, 0.032260162601626, 0.038458509709064, 0.0426165138670682, 0.0467918792115359, 0.0572740595050369,
0.0699859239118166, 0.0764236921521598, 0.0850630010074515, 0.089420299482397, 0.0916084832898368,
0.0959944482021175, 0.102602377717536, 0.109254262418201, 0.113718548132487, 0.118202853065222,
0.120455105317475, 0.12271244166059, 0.127237328538418, 0.1340555103566, 0.13634383987605,
0.138637417857702, 0.140936268432414, 0.143240415897852, 0.145549884720023, 0.147864699534838,
0.150184885149687, 0.152510466545036, 0.157172471207041, 0.159514391581748, 0.161861809422123,
0.164214750598594, 0.16893173173067, 0.173671068223561, 0.176052020604513, 0.178438655449382,
0.180830999946989, 0.183229081481762, 0.185632927635608, 0.188042566189824, 0.190458025127023,
0.192879332633076, 0.195306517099095, 0.197739607123426, 0.20017863151367, 0.202623619288731,
0.205074599680888, 0.20753160213789, 0.209994656325083, 0.212463792127552, 0.214939039652304,
0.217420429230468, 0.219907991419523, 0.222401757005558, 0.224901757005558, 0.229914288333878,
0.232433180021536, 0.234958432546788, 0.237490078116409, 0.240028149182399, 0.242572678444485,
0.247674719260812, 0.252802924389017, 0.255380243976646, 0.257964223304811, 0.26055489687994,
0.263152299477343, 0.26575646614401, 0.268367432201451, 0.273603034295692, 0.27623461324306,
0.278873135670501, 0.281518638316003, 0.284171158209903, 0.286830732677988, 0.292164066011321,
0.294845031158774, 0.297533203201785, 0.300228620991542, 0.302931323694245, 0.305641350794516,
0.308358742098864, 0.311083537739191, 0.313815778176349, 0.319295230231144, 0.322050051167783,
0.322050051167783, 0.322050051167783, 0.322050051167783, 0.322050051167783, 0.324866952576234,
0.327691811333296, 0.327691811333296, 0.327691811333296, 0.330548954190439, 0.333414283703333,
0.333414283703333, 0.333414283703333, 0.333414283703333, 0.333414283703333, 0.33633826031152,
0.339270811631168, 0.339270811631168, 0.339270811631168, 0.339270811631168, 0.339270811631168,
0.339270811631168, 0.339270811631168, 0.342273814634171, 0.342273814634171, 0.345294962670425,
0.345294962670425, 0.345294962670425, 0.345294962670425, 0.345294962670425, 0.345294962670425,
0.345294962670425, 0.348390937902623, 0.348390937902623, 0.351545512035115, 0.351545512035115,
0.351545512035115, 0.351545512035115, 0.351545512035115, 0.351545512035115, 0.351545512035115,
0.351545512035115, 0.354824200559705, 0.354824200559705, 0.358124530592708, 0.361435788870854,
0.361435788870854, 0.361435788870854, 0.364780270476205, 0.364780270476205, 0.364780270476205,
0.368158648854584, 0.368158648854584, 0.368158648854584, 0.368158648854584, 0.368158648854584,
0.368158648854584, 0.368158648854584, 0.368158648854584, 0.368158648854584, 0.368158648854584,
0.368158648854584, 0.368158648854584, 0.371717367715794, 0.371717367715794, 0.375314490017952,
0.378937678423749, 0.382574042060113, 0.382574042060113, 0.382574042060113, 0.382574042060113,
0.386305385343695, 0.386305385343695, 0.390064783839935, 0.393838368745596, 0.393838368745596,
0.393838368745596, 0.393838368745596, 0.393838368745596, 0.393838368745596, 0.393838368745596,
0.393838368745596, 0.393838368745596, 0.397775376619611, 0.401727945789572, 0.401727945789572,
0.401727945789572, 0.405727945789572, 0.4097440100466, 0.413776268111116, 0.417824851107068,
0.421889891757474, 0.421889891757474, 0.421889891757474, 0.426005118094923, 0.430137349499881,
0.430137349499881, 0.434304016166548, 0.438488116584958, 0.442689797257227, 0.442689797257227,
0.44692708539282, 0.451182404541756, 0.45545590881526, 0.459747754308823, 0.464058099136409,
0.468387103465413, 0.47273492955237, 0.477101741779444, 0.481487706691725, 0.485892993035337,
0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399,
0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399,
0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399, 0.490317771796399,
0.495125464104092, 0.495125464104092, 0.495125464104092, 0.495125464104092, 0.500075959153596,
0.500075959153596, 0.505075959153596, 0.505075959153596, 0.505075959153596, 0.505075959153596,
0.505075959153596, 0.510204164281801, 0.510204164281801, 0.510204164281801, 0.515412497615135,
0.515412497615135, 0.515412497615135, 0.515412497615135, 0.515412497615135, 0.515412497615135,
0.515412497615135, 0.515412497615135, 0.515412497615135, 0.520937359493588, 0.520937359493588,
0.520937359493588, 0.520937359493588, 0.526587077007712, 0.526587077007712, 0.526587077007712,
0.526587077007712, 0.532367423828521, 0.538249776769698, 0.538249776769698, 0.538249776769698,
0.538249776769698, 0.538249776769698, 0.538249776769698, 0.538249776769698, 0.538249776769698,
0.538249776769698, 0.538249776769698, 0.538249776769698, 0.538249776769698, 0.538249776769698,
0.538249776769698, 0.538249776769698, 0.538249776769698, 0.538249776769698, 0.544872293325989,
0.544872293325989, 0.544872293325989, 0.544872293325989, 0.544872293325989, 0.544872293325989,
0.544872293325989, 0.544872293325989, 0.551914546847116, 0.551914546847116, 0.551914546847116,
0.551914546847116, 0.551914546847116, 0.551914546847116, 0.551914546847116, 0.551914546847116,
0.551914546847116, 0.551914546847116, 0.551914546847116, 0.551914546847116, 0.559788562595148,
0.559788562595148, 0.559788562595148, 0.559788562595148, 0.559788562595148, 0.576182005218098,
0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098,
0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098,
0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098,
0.576182005218098, 0.576182005218098, 0.576182005218098, 0.576182005218098, 0.586182005218098,
0.596283015319109, 0.606487096951762, 0.616796375302277, 0.627213041968944, 0.637739357758417,
0.648377655630758, 0.659130343802801, 0.669999909020192, 0.680988920009203, 0.692100031120314,
0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494,
0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494,
0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494,
0.703335986176494, 0.703335986176494, 0.703335986176494, 0.703335986176494, 0.718261359310822,
0.718261359310822, 0.718261359310822, 0.718261359310822, 0.718261359310822, 0.718261359310822,
0.718261359310822, 0.718261359310822, 0.718261359310822, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945, 0.735805218959945,
0.735805218959945, 0.735805218959945, 0.819138552293278, 0.819138552293278, 0.819138552293278,
0.819138552293278, 0.819138552293278, 0.819138552293278, 0.819138552293278, 0.819138552293278,
0.819138552293278, 1.15247188562661, 1.65247188562661, 2.65247188562661])
assert_array_almost_equal(y, true_y)