Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Think Stats by Allen B. Downey Think Stats is an introduction to Probability and Statistics for Python programmers.

This is the accompanying code for this book.

Website: http://greenteapress.com/wp/think-stats-2e/

Views: 7089
License: GPL3
1
"""This file contains code for use with "Think Stats",
2
by Allen B. Downey, available from greenteapress.com
3
4
Copyright 2014 Allen B. Downey
5
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
6
"""
7
8
from __future__ import print_function, division
9
10
import unittest
11
import survival
12
13
import thinkstats2
14
import thinkplot
15
16
class Test(unittest.TestCase):
17
18
def testSurvival(self):
19
complete = [1, 2, 3, 4, 5]
20
ongoing = [3, 4, 5]
21
hf = survival.EstimateHazardFunction(complete, ongoing)
22
self.assertAlmostEqual(hf[3], 1/6.0)
23
self.assertAlmostEqual(hf[5], 0.5)
24
25
sf = hf.MakeSurvival()
26
self.assertAlmostEqual(sf[3], 0.625)
27
self.assertAlmostEqual(sf[5], 0.234375)
28
29
30
if __name__ == "__main__":
31
unittest.main()
32
33