Browse Source

Fixes off-by-one error in HW2/p2

Caleb Fangmeier 6 years ago
parent
commit
3db5952012
1 changed files with 2 additions and 2 deletions
  1. 2 2
      HW2/p2.py

+ 2 - 2
HW2/p2.py

@@ -24,7 +24,7 @@ def DL(z):
     den = 0
     for r in range(N+1):
         b = beta.pdf(x, r+1, M)
-        num += b*poisson.cdf(N-r+1, z)
+        num += b*poisson.cdf(N-r, z)
         den += b
     return num/den
 
@@ -43,4 +43,4 @@ root_DR = root(lambda z: DR(z) - (1-p)/2, 10).x[0]
 print(f"The interval is: [{root_DR:.2f}, {root_DL:.2f}]")
 
 # Output
-# > The interval is: [12.39, 22.78]
+# > The interval is: [11.49, 21.68]