コード例 #1
0
 def pmf(self, x: int):
     # P(X = k) = (e^(-ℷ) * ℷ^k) / k!
     return (((exp**(-self.y)) *
              (self.y**x)) / factorial(x)) * RV.I(x in self.samplespace)
コード例 #2
0
 def cdf(self, x):
     #
     return sum([self.pmf(k)
                 for k in range(floor(x) + 1)]) + RV.I(x > self.n)
コード例 #3
0
 def cdf(self, x):
     return (1 - (exp**(-self.y * x))) * RV.I(x in self.samplespace)
コード例 #4
0
 def cdf(self, x):
     # P(X <= K) = (K - a) / (n - a)
     return (x - self.a) / (self.b - self.a) * RV.I(
         x in self.samplespace) + RV.I(x > len(self.samplespace))
コード例 #5
0
 def pmf(self, x):
     # P(X = k) = 1/n
     return 1 / self.n * RV.I(x in self.samplespace)
コード例 #6
0
 def pdf(self, x):
     # P(a <= X <= n) = 1 / (n-a)
     return 1 / (self.b - self.a) * RV.I(x in self.samplespace)
コード例 #7
0
 def pmf(self, x: int) -> int:
     # Given X~B(p) then P(X = k) = p if k == 1, 1-p otherwise
     return (self.p if x == 1 else
             (1 - self.p)) * RV.I(x in self.samplespace)
コード例 #8
0
 def cdf(self, x: (float, int)) -> int:
     # P(X <= K) = ∑ P(X=k), k ∈ [1,n]
     return sum([self.pmf(k)
                 for k in range(floor(x) + 1)]) + RV.I(x > self.n)
コード例 #9
0
 def pmf(self, x: int) -> int:
     # P(X = k) = (n,k) * p^k * (1-p)^(n-k)
     return (comb(self.n, x) * (self.p**x) *
             ((1 - self.p)**(self.n - x))) * RV.I(x in self.samplespace)
コード例 #10
0
 def pmf(self, x: int) -> int:
     # P(X = x) = p(1 - p)^x
     return (((1 - self.p) ** x) * self.p) * RV.I(x in self.samplespace)