File tree Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,7 @@ def test_pmf_simple(self):
6060 def test_pmf_sum (self ):
6161 for n in 10 , 100 , 1_000 , 10_000 :
6262 b = BinomialDist (n , 0.5 )
63- tot = 0
64- for k in range (n + 1 ):
65- tot += b .pmf (k )
66- self .assertAlmostEqual (tot , 1.0 )
63+ self .assertAlmostEqual (sum (b .pmf (k ) for k in range (n + 1 )), 1.0 )
6764
6865 def test_pmf (self ):
6966 for n in 10 , 50 , 100 , 250 :
Original file line number Diff line number Diff line change @@ -75,11 +75,8 @@ def test_pdf(self):
7575 smd = SampleMeanDist (n , k )
7676 N = 1000
7777 dx = n / N
78- p = 0.0
79- for i in range (N + 1 ):
80- x = i * dx
81- p += smd .pdf (x ) * dx
82- self .assertAlmostEqual (p , 1.0 )
78+ self .assertAlmostEqual (
79+ sum (smd .pdf (i * dx ) * dx for i in range (N + 1 )), 1.0 )
8380
8481 def test_cdf (self ):
8582 smd = SampleMeanDist (100 , 30 )
You can’t perform that action at this time.
0 commit comments