Compute the Probability Mass Function (PMF) and Mean of a Geometric distribution.
The Geometric distribution models the number of trials $k$ needed to get the first success in repeated Bernoulli trials with probability of success $p$.
P(X=k)=(1−p)k−1pfor k=1,2,… E[X]=p1k: list or array - Number of trials integers (k ≥ 1)p: float - Probability of success (0 < p ≤ 1)Input: k = [1, 2, 3] p = 0.5
Output: (array([0.5, 0.25, 0.125]), 2.0)
The PMF formula P(X=k)=(1−p)k−1p applies element-wise to k.
Use np.array(k) to convert input to a numpy array for vectorized operations.
The mean is simply 1/p.
(pmf, mean).pmf should be a numpy array of the same shape as k.mean should be a float.numpy.Sign in to take notes on this problem
Accepts: array
Accepts: number
Compute the Probability Mass Function (PMF) and Mean of a Geometric distribution.
The Geometric distribution models the number of trials $k$ needed to get the first success in repeated Bernoulli trials with probability of success $p$.
P(X=k)=(1−p)k−1pfor k=1,2,… E[X]=p1k: list or array - Number of trials integers (k ≥ 1)p: float - Probability of success (0 < p ≤ 1)Input: k = [1, 2, 3] p = 0.5
Output: (array([0.5, 0.25, 0.125]), 2.0)
The PMF formula P(X=k)=(1−p)k−1p applies element-wise to k.
Use np.array(k) to convert input to a numpy array for vectorized operations.
The mean is simply 1/p.
(pmf, mean).pmf should be a numpy array of the same shape as k.mean should be a float.numpy.Sign in to take notes on this problem
Accepts: array
Accepts: number