-
sdr.min_rvs(X: rv_continuous | rv_histogram, Y: rv_continuous | rv_histogram, p: float =
1e-16
) rv_histogram Numerically calculates the distribution of the minimum of two independent random variables \(X\) and \(Y\).
- Parameters:¶
- X: rv_continuous | rv_histogram¶
The distribution of the random variable \(X\).
- Y: rv_continuous | rv_histogram¶
The distribution of the random variable \(Y\).
- p: float =
1e-16
¶ The probability of exceeding the x axis, on either side, for each distribution. This is used to determine the bounds on the x axis for the numerical convolution. Smaller values of \(p\) will result in more accurate analysis, but will require more computation.
- Returns:¶
The distribution of the minimum \(Z = \min(X, Y)\).
Notes
Given two independent random variables \(X\) and \(Y\) with PDFs \(f_X(x)\) and \(f_Y(y)\), and CDFs \(F_X(x)\) and \(F_Y(y)\), we compute the PDF of \(Z = \min(X, Y)\) as follows.
The CDF of \(Z\), denoted \(F_Z(z)\), is \(F_Z(z) = P(Z \leq z)\). Since \(Z = \min(X, Y)\), the event \(Z \leq z\) occurs if either \(X \leq z\) or \(Y \leq z\). Using the complement and independence,
\[P(Z \leq z) = 1 - P(Z > z) = 1 - P(X > z \text{ and } Y > z)\]\[F_Z(z) = 1 - P(X > z) \cdot P(Y > z)\]\[F_Z(z) = 1 - (1 - F_X(z)) \cdot (1 - F_Y(z)) .\]The PDF of \(Z\), denoted \(f_Z(z)\), is the derivative of \(F_Z(z)\). Therefore, \(f_Z(z) = \frac{d}{dz} F_Z(z)\). Substituting \(F_Z(z) = 1 - (1 - F_X(z)) \cdot (1 - F_Y(z))\) yields
\[f_Z(z) = \frac{d}{dz} \big(1 - (1 - F_X(z)) \cdot (1 - F_Y(z))\big)\]\[f_Z(z) = f_X(z) \cdot (1 - F_Y(z)) + f_Y(z) \cdot (1 - F_X(z)) .\]Therefore, the PDF of \(Z = \min(X, Y)\) is
\[f_Z(z) = f_X(z) \cdot (1 - F_Y(z)) + f_Y(z) \cdot (1 - F_X(z))\]where \(F_X(z)\) and \(F_Y(z)\) are the CDFs of the original random variables \(X\) and \(Y\), and \(f_X(z)\) and \(f_Y(z)\) are the PDFs of \(X\) and \(Y\).
Examples
Compute the distribution of the minimum of normal and Rayleigh random variables.
In [1]: X = scipy.stats.norm(loc=3, scale=0.5) In [2]: Y = scipy.stats.rayleigh(loc=1, scale=2) In [3]: x = np.linspace(0, 10, 1_001) In [4]: plt.figure(); \ ...: plt.plot(x, X.pdf(x), label="$X$"); \ ...: plt.plot(x, Y.pdf(x), label="$Y$"); \ ...: plt.plot(x, sdr.min_rvs(X, Y).pdf(x), label=r"$\min(X, Y)$"); \ ...: plt.hist(np.minimum(X.rvs(100_000), Y.rvs(100_000)), bins=101, density=True, histtype="step", label=r"$\min(X, Y)$ empirical"); \ ...: plt.legend(); \ ...: plt.xlabel("Random variable"); \ ...: plt.ylabel("Probability density"); \ ...: plt.title("Minimum of normal and Rayleigh random variables"); ...:
Compute the distribution of the minimum of Rayleigh and Rician random variables.
In [5]: X = scipy.stats.rayleigh(scale=2) In [6]: Y = scipy.stats.rice(2) In [7]: x = np.linspace(0, 8, 1_001) In [8]: plt.figure(); \ ...: plt.plot(x, X.pdf(x), label="$X$"); \ ...: plt.plot(x, Y.pdf(x), label="$Y$"); \ ...: plt.plot(x, sdr.min_rvs(X, Y).pdf(x), label=r"$\min(X, Y)$"); \ ...: plt.hist(np.minimum(X.rvs(100_000), Y.rvs(100_000)), bins=101, density=True, histtype="step", label=r"$\min(X, Y)$ empirical"); \ ...: plt.legend(); \ ...: plt.xlabel("Random variable"); \ ...: plt.ylabel("Probability density"); \ ...: plt.title("Minimum of Rayleigh and Rician random variables"); ...:
Compute the distribution of the minimum of Rician and Chi-squared random variables.
In [9]: X = scipy.stats.rice(3) In [10]: Y = scipy.stats.chi2(3) In [11]: x = np.linspace(0, 20, 1_001) In [12]: plt.figure(); \ ....: plt.plot(x, X.pdf(x), label="$X$"); \ ....: plt.plot(x, Y.pdf(x), label="$Y$"); \ ....: plt.plot(x, sdr.min_rvs(X, Y).pdf(x), label=r"$\min(X, Y)$"); \ ....: plt.hist(np.minimum(X.rvs(100_000), Y.rvs(100_000)), bins=101, density=True, histtype="step", label=r"$\min(X, Y)$ empirical"); \ ....: plt.legend(); \ ....: plt.xlim(0, 15); \ ....: plt.xlabel("Random variable"); \ ....: plt.ylabel("Probability density"); \ ....: plt.title("Minimum of Rician and Chi-squared random variables"); ....: