import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import cv2
import urllib.request
from sympy import *
IMPORTING MODULES AND LIBRARIES
Question 1
Plot the PMF and CDF of Bernoulli, Geometric, Binomial, and Poission random variables. Choose various values of parameters.
BERNOULLI RANDOM VARIABLE
# PMF OF BERNOULLI
= 0.4, 0.8
p1, p2 = stats.bernoulli(p1), stats.bernoulli(p2)
rv_bern1, rv_bern2 = np.array([0, 1])
x = rv_bern1.pmf(x), rv_bern2.pmf(x)
bernoulli1, bernoulli2 = (10, 4))
plt.subplots(figsize
1, 2, 1)
plt.subplot("ro", ms = 12)
plt.plot(x, bernoulli1, 0, bernoulli1, colors = "r", lw = 5, alpha = 0.5)
plt.vlines(x,
plt.grid()f"PMF of Bernoulli with P = {p1}")
plt.title(f"P = {p1}"])
plt.legend(["X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
1, 2, 2)
plt.subplot("bo", ms = 12)
plt.plot(x, bernoulli2, 0, bernoulli2, colors = "b", lw = 5, alpha = 0.5)
plt.vlines(x,
plt.grid()f"PMF of Bernoulli with P = {p2}")
plt.title(f"P = {p2}"])
plt.legend(["X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.show()
# CDF OF BERNOULLI
= np.linspace(-3, 5, 500)
x = rv_bern1.cdf(x), rv_bern2.cdf(x)
bern_cdf1, bern_cdf2
= (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot("r-", ms = 12)
plt.plot(x, bern_cdf1, = 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"P = {p1}"])
plt.legend([
plt.grid()f"CDF of Bernoulli with P = {p1}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
1, 2, 2)
plt.subplot("b-", ms = 12)
plt.plot(x, bern_cdf2, f"P = {p2}"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y
plt.grid()f"CDF of Bernoulli with P = {p2}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel( plt.show()
BINOMIAL RANDOM VARIABLE
# PMF OF BINOMIAL
= np.arange(11)
x = 10, 0.2, 0.6
n, p1, p2 = stats.binom(n, p1), stats.binom(n, p2)
rv_bin1, rv_bin2 = rv_bin1.pmf(x)
binomial1 = rv_bin2.pmf(x)
binomial2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot("go", ms = 10)
plt.plot(x, binomial1, 0, binomial1, colors = "g", lw = 5, alpha = 0.5)
plt.vlines(x, f"(N, p) = ({n}, {p1})"])
plt.legend([
plt.grid()f"PMF of Binomial with (N, p) = ({n}, {p1})")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
1, 2, 2)
plt.subplot("co", ms = 10)
plt.plot(x, binomial2, 0, binomial2, colors = "c", lw = 5, alpha = 0.5)
plt.vlines(x, f"(N, p) = ({n}, {p2})"])
plt.legend([
plt.grid()f"PMF of Binomial with (N, p) = ({n}, {p2})")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.show()
# CDF OF BINOMIAL
= np.linspace(-3, 12, 500)
x = rv_bin1.cdf(x), rv_bin2.cdf(x)
bern_cdf1, bern_cdf2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot('g-', ms = 10)
plt.plot(x, bern_cdf1, = 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"(N, p) = ({n}, {p1})"])
plt.legend([f"CDF of Bernoulli (N, p) = ({n}, {p1})")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid()
1, 2, 2)
plt.subplot('c-', ms = 10)
plt.plot(x, bern_cdf2, f"(N, p) = ({n}, {p2})"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"CDF of Bernoulli (N, p) = ({n}, {p2})")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid() plt.show()
GEOMETRIC RANDOM VARIABLE
# PMF OF GEOMETRIC
= np.arange(1,14)
x = 0.2, 0.6
p1, p2 = stats.geom(p1), stats.geom(p2)
rv_geom1, rv_geom2 = rv_geom1.pmf(x), rv_geom2.pmf(x)
geometric1, geometric2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot("yo", ms = 10)
plt.plot(x, geometric1, 0, geometric1, colors = "y", lw = 5, alpha = 0.5)
plt.vlines(x, f"P = {p1}"])
plt.legend([f"PMF of Geometric with P = {p1}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
1, 2, 2)
plt.subplot("mo", ms = 10)
plt.plot(x, geometric2, 0, geometric2, colors = "m", lw = 5, alpha = 0.5)
plt.vlines(x, f"P = {p2}"])
plt.legend([f"PMF of Geometric with P = {p2}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
plt.show()
# CDF OF GEOMETRIC
= np.linspace(-2, 18, 1000)
x = rv_geom1.cdf(x), rv_geom2.cdf(x)
geom_cdf1, geom_cdf2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot('y-', ms = 10)
plt.plot(x, geom_cdf1, f"P = {p1}"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"CDF of Geometric with P = {p1}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid()
1, 2, 2)
plt.subplot('m-', ms = 10)
plt.plot(x, geom_cdf2, f"P = {p2}"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"CDF of Geometric with P = {p2}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid() plt.show()
POISSON RANDOM VARIABLE
# PMF OF POISSON
= 4, 8
lambd1, lambd2 = np.arange(0, 15)
x = stats.poisson(lambd1), stats.poisson(lambd2)
rv_pois1, rv_pois2 = rv_pois1.pmf(x), rv_pois2.pmf(x)
poisson1, poisson2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot("o", color = "orange", ms = 8)
plt.plot(x, poisson1, 0, poisson1, colors = "orange", lw = 5, alpha = 0.5)
plt.vlines(x, f"λ = {lambd1}"])
plt.legend([f"PMF of Poisson with λ = {lambd1}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
1, 2, 2)
plt.subplot("o", color = "cyan", ms = 8)
plt.plot(x, poisson2, 0, poisson2, colors = "cyan", lw = 5, alpha = 0.5)
plt.vlines(x, f"λ = {lambd2}"])
plt.legend([f"PMF of Poisson λ = {lambd2}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
plt.show()
# CDF OF POISSON
= np.linspace(-1, 18, 1000)
x = rv_pois1.cdf(x), rv_pois2.cdf(x)
pois_cdf1, pois_cdf2 = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot('-', color = "orange", ms = 10)
plt.plot(x, pois_cdf1, f"λ = {lambd1}"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"CDF of Poisson with λ = {lambd1}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid()
1, 2, 2)
plt.subplot('-', color = "cyan", ms = 10)
plt.plot(x, pois_cdf2, f"λ = {lambd2}"])
plt.legend([= 0, linestyle = "--")
plt.axvline(x = 0, linestyle = "--")
plt.axhline(y f"CDF of Poisson λ = {lambd2}")
plt.title("X (Random Variable)")
plt.xlabel("sum (P(X))")
plt.ylabel(
plt.grid() plt.show()
Question 2
Show the equivalence and the difference between various choices of parameters for Binomial and Poission distributions. Use both PMF and CDF.
# CASE 1
= 50, 0.8
n, p = np.arange(0, n+1)
bin_values = stats.binom.pmf(bin_values, n, p)
bin_probs "g")
plt.stem(bin_values, bin_probs,
= n * p
lambd = stats.poisson(lambd)
rv2 = np.arange(0, 100)
x_values = rv2.pmf(x_values)
f = "magenta")
plt.plot(x_values, f, color f"Poisson with λ = N * p", f"Binomial with ({n}, {p})"])
plt.legend([0, 70])
plt.xlim([0, 0.16])
plt.ylim(["Random Varible (X)")
plt.xlabel("P(X)")
plt.ylabel(f"Both DO NOT MATCH as N ({n}) is SMALL and p ({p}) is LARGE")
plt.title(
plt.grid()
plt.show()
# CASE 2
= 100, 0.5
n, p = np.arange(0, n+1)
bin_values = stats.binom.pmf(bin_values, n, p)
bin_probs "g")
plt.stem(bin_values, bin_probs,
= n * p
lambd = stats.poisson(lambd)
rv2 = np.arange(0, 100)
x_values = rv2.pmf(x_values)
f = "magenta")
plt.plot(x_values, f, color f"Poisson with λ = N * p", f"Binomial with ({n}, {p})"])
plt.legend([0, 80])
plt.xlim([0, 0.1])
plt.ylim(["Random Varible (X)")
plt.xlabel("P(X)")
plt.ylabel(f"Both try to approach as still N ({n}) is small and p ({p}) is large")
plt.title(
plt.grid()
plt.show()
# CASE 3
= 1000, 0.05
n, p = np.arange(0, n+1)
bin_values = stats.binom.pmf(bin_values, n, p)
bin_probs "g")
plt.stem(bin_values, bin_probs,
= n * p
lambd = stats.poisson(lambd)
rv2 = np.arange(0, 100)
x_values = rv2.pmf(x_values)
f = "magenta")
plt.plot(x_values, f, color f"Poisson with λ = N * p", f"Binomial with ({n}, {p})"])
plt.legend([0, 80])
plt.xlim([0, 0.06])
plt.ylim(["Random Varible (X)")
plt.xlabel("P(X)")
plt.ylabel(f"Both MATCH as N ({n}) is LARGE and p ({p}) is SMALL")
plt.title(
plt.grid()
plt.show()print("HENCE AS N TENDS TO INFINITY AND p TENDS TO 0,\nTHE BINOMIAL RANDOM VARIABLE ACTUALLY BECOMES THE POISSON\nWHOSE λ = N * p")
HENCE AS N TENDS TO INFINITY AND p TENDS TO 0,
THE BINOMIAL RANDOM VARIABLE ACTUALLY BECOMES THE POISSON
WHOSE λ = N * p
Question 3
Read an image and add different amounts of Gaussian Noise and display the corrupted images.
COLORED IMAGE
= urllib.request.urlopen("https://source.unsplash.com/fusZEKsVZL0")
url = np.asarray(bytearray(url.read()), dtype = np.uint8)
arr = cv2.imdecode(arr, -1)
img # print(img.shape)
= np.zeros(img.shape, dtype = np.uint8)
gaussian_noise = 100, 100
mean, sigma
cv2.randn(gaussian_noise, mean, sigma)= (gaussian_noise * 0.5).astype(np.uint8)
gaussian_noise = cv2.add(img, gaussian_noise)
gn_img
= plt.figure(dpi = 300)
fig 1, 3, 1)
fig.add_subplot(
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))"off")
plt.axis("Colored Image")
plt.title(
1, 3, 2)
fig.add_subplot(= "gray")
plt.imshow(gaussian_noise, cmap "off")
plt.axis("Gaussian Noise")
plt.title(
1, 3, 3)
fig.add_subplot(
plt.imshow(cv2.cvtColor(gn_img, cv2.COLOR_BGR2RGB))"off")
plt.axis("Final Image")
plt.title( plt.show()
BLACK & WHITE IMAGE
= urllib.request.urlopen("https://source.unsplash.com/fusZEKsVZL0")
url = np.asarray(bytearray(url.read()), dtype = np.uint8)
arr = cv2.imdecode(arr, 0)
img # print(img.shape)
= np.zeros(img.shape, dtype = np.uint8)
gaussian_noise = 100, 100
mean, sigma
cv2.randn(gaussian_noise, mean, sigma)= (gaussian_noise * 0.5).astype(np.uint8)
gaussian_noise = cv2.add(img, gaussian_noise)
gn_img
= plt.figure(dpi = 300)
fig 1, 3, 1)
fig.add_subplot(
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))"off")
plt.axis("B&W Image")
plt.title(
1, 3, 2)
fig.add_subplot(= "gray")
plt.imshow(gaussian_noise, cmap "off")
plt.axis("Gaussian Noise")
plt.title(
1, 3, 3)
fig.add_subplot(
plt.imshow(cv2.cvtColor(gn_img, cv2.COLOR_BGR2RGB))"off")
plt.axis("Final Image")
plt.title( plt.show()
Question 4
Plot the PDF and CDF of the following random variables for different parameter values. - Uniform - Exponential - Rayleigh - Laplacian - Gaussian (Normal) - Chi-square - Erlang - Log-normal - Cauchy - Beta - Weibull
UNIFORM RANDOM VARIABLE
print("X ~ UNIFORM(a, b)")
= ((0.1, 0.6), (0.5, 1.5))
AB
= np.linspace(AB[0][0] - 1 , AB[0][1] + 1, 100), np.linspace(AB[1][0] - 1 , AB[1][1] + 1, 100)
x
= stats.uniform(loc = AB[0][0], scale = AB[0][1] - AB[0][0])
uni_dist1 = stats.uniform(loc = AB[1][0], scale = AB[1][1] - AB[1][0])
uni_dist2
= uni_dist1.pdf(x[0]), uni_dist2.pdf(x[1])
pdf = uni_dist1.cdf(x[0]), uni_dist2.cdf(x[1])
cdf = ["green", "red"]
color for i in range(2):
= (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= 5, color = color[i])
plt.plot(x[i], pdf[i], linewidth f"PDF of Uniform RV with a, b = {AB[i]}")
plt.title("X")
plt.xlabel("P(X)")
plt.ylabel(f"(a, b) = {AB[i]}"])
plt.legend([
plt.grid()
1, 2, 2)
plt.subplot(= 5, color = color[i])
plt.plot(x[i], cdf[i], linewidth f"CDF of Uniform RV with a, b = {AB[i]}")
plt.title("X")
plt.xlabel("F(X)")
plt.ylabel(f"(a, b) = {AB[i]}"])
plt.legend([
plt.grid() plt.show()
X ~ UNIFORM(a, b)
EXPONENTIAL RANDOM VARIABLE
print("X ~ EXPONENTIAL(λ)")
= 0.5, 0.2
lambd = np.linspace(-0.3, 1.5, 1000)
x = ["blue", "orange"]
color for i in range(2):
= stats.expon.pdf(x, scale = lambd[i])
f = stats.expon.cdf(x, scale = lambd[i])
F = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, f, color "X")
plt.xlabel("P(X)")
plt.ylabel(f"λ = {1/lambd[i]}"])
plt.legend([f"PDF of Exponential RV with λ = {1/lambd[i]}")
plt.title(
plt.grid()1, 2, 2)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, F, color "X")
plt.xlabel("F(X)")
plt.ylabel(f"λ = {1/lambd[i]}"])
plt.legend([f"CDF of Exponential RV with λ = {1/lambd[i]}")
plt.title(
plt.grid() plt.show()
X ~ EXPONENTIAL(λ)
RAYLEIGH RANDOM VARIABLE
print("X ~ RAYLEIGH(s)")
= 1, 5
lambd = np.linspace(0, 15, 1000)
x = ["pink", "cyan"]
color for i in range(2):
= stats.rayleigh.pdf(x, scale = lambd[i])
f = stats.rayleigh.cdf(x, scale = lambd[i])
F = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, f, color = lambd[i], color = "green", linestyle = "--")
plt.axvline(x "X")
plt.xlabel("P(X)")
plt.ylabel(f"s = {lambd[i]}"])
plt.legend([f"PDF of Rayleigh RV with s = {lambd[i]}")
plt.title(
plt.grid()1, 2, 2)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, F, color "X")
plt.xlabel("F(X)")
plt.ylabel(f"s = {lambd[i]}"])
plt.legend([f"CDF of Rayleigh RV with s = {lambd[i]}")
plt.title(
plt.grid()
plt.show()print("The mode lies at s")
X ~ RAYLEIGH(s)
The mode lies at s
LAPLACIAN RANDOM VARIABLE
print("X ~ LAPLACIAN(µ, b)")
= 0, 2
mu = 1, 3
b = np.linspace(-7, 7, 1000)
x
= stats.laplace.pdf(x, mu[0], b[0]), stats.laplace.pdf(x, mu[0], b[1]), stats.laplace.pdf(x, mu[1], b[0]), stats.laplace.pdf(x, mu[1], b[1])
pdf = stats.laplace.cdf(x, mu[0], b[0]), stats.laplace.cdf(x, mu[0], b[1]), stats.laplace.cdf(x, mu[1], b[0]), stats.laplace.cdf(x, mu[1], b[1]),
cdf = ["red", "green"]
color for i in range(0, 3, 2):
= 0
c = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[c])
plt.plot(x, pdf[i], color + 1], color = color[c + 1])
plt.plot(x, pdf[i = mu[i // 2], linestyle = "--")
plt.axvline(x f"b = {b[c]}", f"b = {b[c + 1]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Laplacian with µ = {mu[i // 2]}")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[c])
plt.plot(x, cdf[i], color + 1], color = color[c + 1])
plt.plot(x, cdf[i = mu[i // 2], linestyle = "--")
plt.axvline(x f"b = {b[c]}", f"b = {b[c + 1]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Laplacian with µ = {mu[i // 2]}")
plt.title(
plt.grid()
plt.show()print("Changing the MEAN (µ) shifts the PDF/CDF LEFT or RIGHT\nwhereas, Changing the b, changes the height of the PDF in an inverse manner")
X ~ LAPLACIAN(µ, b)
Changing the MEAN (µ) shifts the PDF/CDF LEFT or RIGHT
whereas, Changing the b, changes the height of the PDF in an inverse manner
GAUSSIAN(NORMAL) RANDOM VARIABLE
print("X ~ GAUSSIAN(µ, σ^2) or X ~ N(µ, σ^2)")
= 0, 1
mu = 1, 2
sigma = np.linspace(-5, 5, 1000)
x
= stats.norm.pdf(x, mu[0], sigma[0]), stats.norm.pdf(x, mu[0], sigma[1]), stats.norm.pdf(x, mu[1], sigma[0]), stats.norm.pdf(x, mu[1], sigma[1])
pdf = stats.norm.cdf(x, mu[0], sigma[0]), stats.norm.cdf(x, mu[0], sigma[1]), stats.norm.cdf(x, mu[1], sigma[0]), stats.norm.cdf(x, mu[1], sigma[1]),
cdf
for i in range(0, 3, 2):
= 0
c = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(
plt.plot(x, pdf[i])+ 1])
plt.plot(x, pdf[i = mu[i // 2], linestyle = "--", color = "green")
plt.axvline(x f"σ = {sigma[c]}", f"σ = {sigma[c + 1]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Gaussian with µ = {mu[i // 2]}")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(
plt.plot(x, cdf[i])+ 1])
plt.plot(x, cdf[i = mu[i // 2], linestyle = "--", color = "green")
plt.axvline(x f"σ = {sigma[c]}", f"σ = {sigma[c + 1]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Gaussian with µ = {mu[i // 2]}")
plt.title(
plt.grid()
plt.show()print("Changing the MEAN (µ) shifts the PDF/CDF LEFT or RIGHT\nwhereas, Changing the Variance(σ^2), STRECHES OR SQUISHES the PDF/CDF")
X ~ GAUSSIAN(µ, σ^2) or X ~ N(µ, σ^2)
Changing the MEAN (µ) shifts the PDF/CDF LEFT or RIGHT
whereas, Changing the Variance(σ^2), STRECHES OR SQUISHES the PDF/CDF
CHI-SQUARE RANDOM VARIABLE
print("X ~ χ^2(k)")
= 2, 4, 9
k = np.linspace(0, 20, 1000)
x = ["orange", "blue", "red"]
color for i in range(3):
= stats.chi2.pdf(x, df = k[i])
f = stats.chi2.cdf(x, df = k[i])
F = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, f, color = k[i] - 2, color = "green", linestyle = "--")
plt.axvline(x "X")
plt.xlabel("P(X)")
plt.ylabel(f"k = {k[i]}"])
plt.legend([f"PDF of Chi-squared RV with k = {k[i]}")
plt.title(
plt.grid()1, 2, 2)
plt.subplot(= color[i], linewidth = 4)
plt.plot(x, F, color "X")
plt.xlabel("F(X)")
plt.ylabel(f"k = {k[i]}"])
plt.legend([f"CDF of Chi-squared RV with k = {k[i]}")
plt.title(
plt.grid()
plt.show()print("The mode lies at k - 2")
X ~ χ^2(k)
The mode lies at k - 2
ERLANG RANDOM VARIABLE
print("X ~ ERLANG(k, λ)")
= 1, 5, 7
k = 0.5, 1, 2
lambd = np.linspace(0, 20, 1000)
x = ["olive", "cyan", "pink"]
color for i in range(0, 3):
= stats.erlang.pdf(x, k[i], scale = 1/lambd[i])
pdf = stats.erlang.cdf(x, k[i], scale = 1/lambd[i])
cdf = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i])
plt.plot(x, pdf, color = (k[i] - 1)/lambd[i], linestyle = "--")
plt.axvline(x f"k={k[i]}, λ={lambd[i]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Erlang RV with (k, λ)")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[i])
plt.plot(x, cdf, color f"k={k[i]}, λ={lambd[i]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Erlang RV with (k, λ)")
plt.title(
plt.grid()
plt.show()print("The mode now lies at (k - 1)/λ")
X ~ ERLANG(k, λ)
The mode now lies at (k - 1)/λ
LOG-NORMAL RANDOM VARIABLE
print("X ~ LOGNORMAL(µ, σ^2)\nOR\nLOG(X) ~ GAUSSIAN(µ, σ^2)")
= 0, 0.5, 1
mu = 0.25, 0.5, 1
sigma = np.linspace(0, 10, 1000)
x = ["crimson", "blueviolet", "teal"]
color for i in range(0, 3):
= stats.lognorm.pdf(x, sigma[i], scale = np.exp(mu[i]))
pdf = stats.lognorm.cdf(x, sigma[i], scale = np.exp(mu[i]))
cdf = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i])
plt.plot(x, pdf, color = np.exp(mu[i] - sigma[i]**2), linestyle = "--")
plt.axvline(x f"µ={mu[i]}, σ={sigma[i]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Log-Normal RV with (µ, σ)")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[i])
plt.plot(x, cdf, color f"µ={mu[i]}, σ={sigma[i]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Log-Normal RV with (µ, σ)")
plt.title(
plt.grid()
plt.show()print("The mode now lies at exp(µ - σ^2)")
X ~ LOGNORMAL(µ, σ^2)
OR
LOG(X) ~ GAUSSIAN(µ, σ^2)
The mode now lies at exp(µ - σ^2)
CAUCHY RANDOM VARIABLE
print("X ~ CAUCHY(m, b)")
= 0, 1
mu = 1, 2
b = np.linspace(-5, 5, 1000)
x
= stats.cauchy.pdf(x, mu[0], b[0]), stats.cauchy.pdf(x, mu[0], b[1]), stats.cauchy.pdf(x, mu[1], b[0]), stats.cauchy.pdf(x, mu[1], b[1])
pdf = stats.cauchy.cdf(x, mu[0], b[0]), stats.cauchy.cdf(x, mu[0], b[1]), stats.cauchy.cdf(x, mu[1], b[0]), stats.cauchy.cdf(x, mu[1], b[1]),
cdf = ["purple", "green"]
color for i in range(0, 3, 2):
= 0
c = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[c])
plt.plot(x, pdf[i], color + 1], color = color[c + 1])
plt.plot(x, pdf[i = mu[i // 2], linestyle = "--")
plt.axvline(x f"b = {b[c]}", f"b = {b[c + 1]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Cauchy with m = {mu[i // 2]}")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[c])
plt.plot(x, cdf[i], color + 1], color = color[c + 1])
plt.plot(x, cdf[i = mu[i // 2], linestyle = "--")
plt.axvline(x f"b = {b[c]}", f"b = {b[c + 1]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Cauchy with m = {mu[i // 2]}")
plt.title(
plt.grid()
plt.show()print("Changing the m shifts the PDF/CDF LEFT or RIGHT\nwhereas, Changing the b, changes the height of the PDF in an inverse manner")
X ~ CAUCHY(m, b)
Changing the m shifts the PDF/CDF LEFT or RIGHT
whereas, Changing the b, changes the height of the PDF in an inverse manner
BETA RANDOM VARIABLE
print("X ~ BETA(a, b)")
= 0.5, 2, 2, 5
a = 0.5, 2, 5, 1
b = np.linspace(0, 1, 100)
x = ["chartreuse", "darkviolet", "limegreen", "orangered"]
color for i in range(4):
= stats.beta.pdf(x, a[i], b[i])
pdf = stats.beta.cdf(x, a[i], b[i])
cdf = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i])
plt.plot(x, pdf, color if (a[i] > 1 and b[i] > 1):
= (a[i] - 1)/(a[i] + b[i] - 2), linestyle = "--")
plt.axvline(x f"a={a[i]}, b={b[i]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Beta RV with (a, b) = ({a[i]}, {b[i]})")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[i])
plt.plot(x, cdf, color f"a={a[i]}, b={b[i]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Beta RV with (a, b) = ({a[i]}, {b[i]})")
plt.title(
plt.grid()
plt.show()print("The mode now lies at (a - 1)/(a + b - 2) if a, b > 1 and can vary for other values")
X ~ BETA(a, b)
The mode now lies at (a - 1)/(a + b - 2) if a, b > 1 and can vary for other values
WEIBULL RANDOM VARIABLE
print("X ~ WEIBULL(λ, k)")
= 0.5, 1, 1.5, 5
k = 1, 1, 1, 1
lambd = np.linspace(0, 3, 500)
x = ["deepskyblue", "palegreen", "gold", "hotpink"]
color for i in range(4):
= stats.weibull_min.pdf(x, k[i], scale = 1/lambd[i])
pdf = stats.weibull_min.cdf(x, k[i], scale = 1/lambd[i])
cdf = (10, 4))
plt.subplots(figsize 1, 2, 1)
plt.subplot(= color[i])
plt.plot(x, pdf, color if k[i] > 1:
= lambd[i] * ((k[i] - 1)/k[i])**(1 / k[i]), linestyle = "--")
plt.axvline(x else:
= 0, linestyle = "--")
plt.axvline(x f"λ={lambd[i]}, k={k[i]}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Weibull RV with (λ, k) = ({lambd[i]}, {k[i]})")
plt.title(
plt.grid()
1, 2, 2)
plt.subplot(= color[i])
plt.plot(x, cdf, color f"λ={lambd[i]}, k={k[i]}"])
plt.legend(['X')
plt.xlabel('F(X)')
plt.ylabel(f"CDF of Weibull RV with (λ, k) = ({lambd[i]}, {k[i]})")
plt.title(
plt.grid()
plt.show()print("The mode now lies at λ * ((k - 1)/k)^(1/k) for k > 1 and at 0 for k =< 1")
X ~ WEIBULL(λ, k)
The mode now lies at λ * ((k - 1)/k)^(1/k) for k > 1 and at 0 for k =< 1
/usr/local/lib/python3.9/dist-packages/scipy/stats/_continuous_distns.py:2267: RuntimeWarning: divide by zero encountered in power
return c*pow(x, c-1)*np.exp(-pow(x, c))
Question 5
Find the Expectation and variance for all the random variables in Question 1 & 4. Further, find and/or plot their characteristic functions.
= symbols("p j ω µ λ b σ n a s k")
prob, j, w, mt, lamb, bt, sig, nt, at, st, kt ## X ~ BERNOUILLI(p)
= 0.6
p = stats.bernoulli.stats(p, moments = "mv")
m, v = 1 - prob + prob*exp(j*w)
expr print(f"\n1.) X ~ BERNOUILLI(p = {p}):\nE[X]:")
display(prob)print("Var[X]:")
* (1 - prob))
display(prob print("Characteristic Function φ(ω)=")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.array([0, 1])
x = stats.bernoulli(p).pmf(x)
bernoulli "ro", ms = 12)
plt.plot(x, bernoulli, 0, bernoulli, colors = "r", lw = 5, alpha = 0.5)
plt.vlines(x, = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"P = {p}", "", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([
plt.grid()f"PMF of Bernoulli with P = {p}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.show()
## X ~ BINOMIAL(n, p)
= 10, 0.4
n, p = stats.binom.stats(n, p, moments = "mv")
m, v = (1 - prob + prob*exp(j*w))**nt
expr print(f"\n2.) X ~ BINOMIAL(n = {n}, p = {p}):\nE[X]:")
* prob)
display(nt print("Var[X]:")
* prob * (1 - prob))
display(nt print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.arange(n + 1)
x = stats.binom(n, p).pmf(x)
binomial "go", ms = 10)
plt.plot(x, binomial, 0, binomial, colors = "g", lw = 5, alpha = 0.5)
plt.vlines(x, = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(n,p)=({n},{p})", "", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([
plt.grid()f"PMF of Binomial with (n, p) = ({n}, {p})")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.show()
## X ~ GEOMETRIC(p)
= 0.2
p = stats.geom.stats(p, moments = "mv")
m, v = prob * exp(j * w)/(1 - (1 - prob)*exp(j * w))
expr print(f"\n3.) X ~ GEOMETRIC(p = {p}):\nE[X]:")
1/prob)
display(print("Var[X]:")
1 - prob)/prob**2)
display((print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.arange(1,v+1)
x = stats.geom(p).pmf(x)
geometric "yo", ms = 10)
plt.plot(x, geometric, 0, geometric, colors = "y", lw = 5, alpha = 0.5)
plt.vlines(x, = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"P = {p}", "", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PMF of Geometric with P = {p}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
plt.show()
## X ~ POISSON(λ)
= 4
lambd = stats.poisson.stats(lambd, moments = "mv")
m, v = exp(lamb * (exp(j * w) - 1))
expr print(f"\n4.) X ~ POISSON(λ = {lambd}):\nE[X]:")
display(lamb)print("Var[X]:")
display(lamb)print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.arange(0, 15)
x = stats.poisson(lambd).pmf(x)
poisson "o", color = "orange", ms = 8)
plt.plot(x, poisson, 0, poisson, colors = "orange", lw = 5, alpha = 0.5)
plt.vlines(x, = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"λ = {lambd}", "", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PMF of Poisson with λ = {lambd}")
plt.title("X (Random Variable)")
plt.xlabel("P(X)")
plt.ylabel(
plt.grid()
plt.show()
## X ~ UNIFORM(a, b)
= 0.5, 1.5
a, b = stats.uniform.stats(loc = a, scale = b - a, moments = "mv")
m, v = (exp(bt * j * w) - exp(at * j * w))/(j * w * (bt - at))
expr print(f"\n5.) X ~ UNIFORM(a = {a}, b = {b}):\nE[X]:")
+ bt)/2)
display((at print("Var[X]:")
- at)**2/12)
display((bt print("Characteristic Function φ(ω) = ")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(a - 1, b + 1, 100)
x = stats.uniform(loc = a, scale = b - a).pdf(x)
pdf = 4, color = "purple")
plt.plot(x, pdf, linewidth f"PDF of Uniform RV with a, b = {(a, b)}")
plt.title("X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(a,b)=({a},{b})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([
plt.grid()
plt.show()
## X ~ EXPONENTIAL(λ)
= 0.5
lambd = stats.expon.stats(scale = lambd, moments = "mv")
m, v = lamb/(lamb - j*w)
expr print(f"\n6.) X ~ EXPONENTIAL(λ = {1/lambd}):\nE[X]:")
1/lamb)
display(print("Var[X]:")
1/lamb**2)
display(print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(-0.3, 1.5, 1000)
x = stats.expon.pdf(x, scale = lambd)
f = "blue", linewidth = 4)
plt.plot(x, f, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"λ = {1/lambd}", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Exponential RV with λ = {1/lambd}")
plt.title(
plt.grid()
plt.show()
## X ~ RAYLEIGH(s)
= 5
lambd = stats.rayleigh.stats(scale = lambd, moments = "mv")
m, v = symbols("p j ω µ λ b σ n a s k")
prob, j, w, mt, lamb, bt, sig, nt, at, st, kt = 1 - (st * w * exp(- w**2 * st**2 / 2) * sqrt(pi/2) * (erf(st * w/sqrt(2)) - j))
expr print(f"\n7.) X ~ RAYLEIGH(s = {lambd}):\nE[X]:")
* sqrt(pi/2))
display(st print("Var[X]:")
**2 * (4 - pi)/2)
display(stprint("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 15, 1000)
x = stats.rayleigh.pdf(x, scale = lambd)
f = "pink", linewidth = 4)
plt.plot(x, f, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"s = {1/lambd}", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Rayleigh RV with s = {lambd}")
plt.title(
plt.grid()
plt.show()
## X ~ LAPLACIAN(µ, b)
= 2, 2
mu, b = stats.laplace.stats(mu, b, moments = "mv")
m, v = exp(j * w * mt)/(1 + bt**2 * w**2)
expr print(f"\n8.) X ~ LAPLACIAN(µ = {mu}, b = {b}):\nE[X]:")
display(mt)print("Var[X]:")
2 * bt**2)
display(print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(-7, 10, 1000)
x = stats.laplace.pdf(x, mu, b)
pdf = "red", linewidth = 4)
plt.plot(x, pdf, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(µ,b)=({mu},{b})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Laplacian with (µ, b) = ({mu}, {b})")
plt.title(
plt.grid()
plt.show()
## X ~ GAUSSIAN(µ, σ^2)
= 1, 2
mu, sigma = stats.norm.stats(mu, sigma, moments = "mv")
m, v = exp(mt * j * w - (sig**2 * w**2)/2)
expr print(f"\n9.) X ~ GAUSSIAN(µ = {mu}, σ^2 = {sigma**2}):\nE[X]:")
display(mt)print("Var[X]:")
**2)
display(sigprint("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(-5, 7, 1000)
x = stats.norm.pdf(x, mu, sigma)
pdf = "blueviolet", linewidth = 4)
plt.plot(x, pdf, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(µ,σ^2)=({mu},{sigma**2})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Gaussian with (µ, σ^2) = ({mu}, {sigma**2})")
plt.title(
plt.grid()
plt.show()
## X ~ χ^2(k)
= 4
k = stats.chi2.stats(df = k, moments = "mv")
m, v = (1 - 2*j*w)**(-kt/2)
expr print(f"\n10.) X ~ χ^2(k = {k}):\nE[X]:")
display(kt)print("Var[X]:")
2 * kt)
display(print("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 20, 1000)
x = stats.chi2.pdf(x, df = k)
f = "olive", linewidth = 4)
plt.plot(x, f, color = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x "X")
plt.xlabel("P(X)")
plt.ylabel(f"k = {k}", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Chi-squared RV with k = {k}")
plt.title(
plt.grid()
plt.show()
## X ~ ERLANG(k, λ)
= 7, 2
k, lambd = stats.erlang.stats(k, scale = 1/lambd, moments = "mv")
m, v = (1 - (j * w)/kt)**(-kt)
expr print(f"\n11.) X ~ ERLANG(k = {k}, λ = {lambd}):\nE[X]:")
/lamb)
display(ktprint("Var[X]:")
/lamb**2)
display(ktprint("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 11, 1000)
x = stats.erlang.pdf(x, k, scale = 1/lambd)
pdf = "teal", linewidth = 4)
plt.plot(x, pdf, color = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(k,λ)=({k},{lambd})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Erlang RV with (k, λ)")
plt.title(
plt.grid()
plt.show()
## X ~ LOGNORMAL(µ, σ^2)
= 0.5, 0.5
mu, sigma = stats.lognorm.stats(sigma, scale = np.exp(mu), moments = "mv")
m, v = Sum((j * w)**nt/(factorial(nt)) * exp(mt * nt + nt**2 * sig**2/2), (nt, 0, oo))
expr print(f"\n12.) X ~ LOGNORMAL(µ = {mu}, σ^2 = {sigma**2})):\nE[X]:")
+ sig**2/2))
display(exp(mt print("Var[X]:")
**2) - 1)*exp(2*mt + sig**2))
display((exp(sigprint("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 7, 1000)
x = stats.lognorm.pdf(x, sigma, scale = np.exp(mu))
pdf = "crimson", linewidth = 4)
plt.plot(x, pdf, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(µ,σ^2)=({mu},{sigma**2})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Log-Normal with (µ, σ^2) = ({mu}, {sigma**2})")
plt.title(
plt.grid()
plt.show()
## X ~ CAUCHY(m, b)
= 1, 2
mu, b = stats.cauchy.stats(mu, b, moments = "mv")
m, v print(f"\n13.) X ~ CAUCHY(m = {mu}, b = {b}):\nE[X] = undefined\nVar[X] = undefined\nCharacteristic Function φ(ω) =\nundefined\nE[X] : {m}\nVar[X] : {v}\n")
= np.linspace(-5, 6, 1000)
x = stats.cauchy.pdf(x, mu, b)
pdf = "violet", linewidth = 4)
plt.plot(x, pdf, color "X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(µ,b)=({mu},{b})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([f"PDF of Cauchy with (µ, b) = ({mu}, {b})")
plt.title(
plt.grid()
plt.show()
## X ~ BETA(a, b)
= 2, 5
a, b = stats.beta.stats(a, b, moments = "mv")
m, v print(f"\n14.) X ~ BETA(a = {a}, b = {b}):\nE[X]:")
/(at + bt))
display(atprint("Var[X]:")
* bt)/((at + bt)**2 * (at + bt + 1)))
display((at print(f"Characteristic Function φ(ω) =\nHIGHLY COMPLEX, requires confluent hypergeometric functions to display in closed form\nE[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 1, 100)
x = stats.beta.pdf(x, a, b)
pdf = 4, color = "limegreen")
plt.plot(x, pdf, linewidth f"PDF of BETA RV with a, b = {(a, b)}")
plt.title("X")
plt.xlabel("P(X)")
plt.ylabel(= m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(a,b)=({a},{b})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend([
plt.grid()
plt.show()
## X ~ WEIBULL(λ, k)
= 5, 1
k, lambd = stats.weibull_min.stats(k, scale = 1/lambd, moments = "mv")
m, v = Sum(((j*w)**nt/(factorial(nt)) * lamb**nt * gamma(1 + nt/kt)), (nt, 0, oo))
expr print(f"\n15.) X ~ WEIBULL(λ = {lambd}, k = {k}):\nE[X]:")
* gamma(1 + 1/kt))
display(lamb print("Var[X]:")
**2 * (gamma(1 + 2/kt) - (gamma(1 + 1/kt))**2))
display(lambprint("Characteristic Function φ(ω) =")
display(expr)print(f"E[X] : {m}\nVar[X] : {v}\n")
= np.linspace(0, 3, 500)
x = stats.weibull_min.pdf(x, k, scale = 1/lambd)
pdf = "deepskyblue", linewidth = 4)
plt.plot(x, pdf, color = m, linestyle = "--")
plt.axvline(x = v, linestyle = "--", color = "orange")
plt.axvline(x f"(λ,k)=({lambd},{k})", f"E[X] : {m}", f"Var[X] : {v}"])
plt.legend(["X")
plt.xlabel("P(X)")
plt.ylabel(f"PDF of Weibull RV with (λ, k)")
plt.title(
plt.grid() plt.show()
1.) X ~ BERNOUILLI(p = 0.6):
E[X]:
Var[X]:
Characteristic Function φ(ω)=
E[X] : 0.6
Var[X] : 0.24
2.) X ~ BINOMIAL(n = 10, p = 0.4):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 4.0
Var[X] : 2.4
3.) X ~ GEOMETRIC(p = 0.2):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 5.0
Var[X] : 20.0
4.) X ~ POISSON(λ = 4):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 4.0
Var[X] : 4.0
5.) X ~ UNIFORM(a = 0.5, b = 1.5):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 1.0
Var[X] : 0.08333333333333333
6.) X ~ EXPONENTIAL(λ = 2.0):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 0.5
Var[X] : 0.25
7.) X ~ RAYLEIGH(s = 5):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 6.2665706865775
Var[X] : 10.730091830127586
8.) X ~ LAPLACIAN(µ = 2, b = 2):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 2.0
Var[X] : 8.0
9.) X ~ GAUSSIAN(µ = 1, σ^2 = 4):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 1.0
Var[X] : 4.0
10.) X ~ χ^2(k = 4):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 4.0
Var[X] : 8.0
11.) X ~ ERLANG(k = 7, λ = 2):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 3.5
Var[X] : 1.75
12.) X ~ LOGNORMAL(µ = 0.5, σ^2 = 0.25)):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 1.8682459574322225
Var[X] : 0.9913461128762231
13.) X ~ CAUCHY(m = 1, b = 2):
E[X] = undefined
Var[X] = undefined
Characteristic Function φ(ω) =
undefined
E[X] : nan
Var[X] : nan
14.) X ~ BETA(a = 2, b = 5):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
HIGHLY COMPLEX, requires confluent hypergeometric functions to display in closed form
E[X] : 0.2857142857142857
Var[X] : 0.025510204081632654
15.) X ~ WEIBULL(λ = 1, k = 5):
E[X]:
Var[X]:
Characteristic Function φ(ω) =
E[X] : 0.9181687423997608
Var[X] : 0.04422997798311701
\(\displaystyle p\)
\(\displaystyle p \left(1 - p\right)\)
\(\displaystyle p e^{j ω} - p + 1\)
\(\displaystyle n p\)
\(\displaystyle n p \left(1 - p\right)\)
\(\displaystyle \left(p e^{j ω} - p + 1\right)^{n}\)
\(\displaystyle \frac{1}{p}\)
\(\displaystyle \frac{1 - p}{p^{2}}\)
\(\displaystyle \frac{p e^{j ω}}{- \left(1 - p\right) e^{j ω} + 1}\)
\(\displaystyle λ\)
\(\displaystyle λ\)
\(\displaystyle e^{λ \left(e^{j ω} - 1\right)}\)
\(\displaystyle \frac{a}{2} + \frac{b}{2}\)
\(\displaystyle \frac{\left(- a + b\right)^{2}}{12}\)
\(\displaystyle \frac{- e^{a j ω} + e^{b j ω}}{j ω \left(- a + b\right)}\)
\(\displaystyle \frac{1}{λ}\)
\(\displaystyle \frac{1}{λ^{2}}\)
\(\displaystyle \frac{λ}{- j ω + λ}\)
\(\displaystyle \frac{\sqrt{2} \sqrt{\pi} s}{2}\)
\(\displaystyle \frac{s^{2} \left(4 - \pi\right)}{2}\)
\(\displaystyle - \frac{\sqrt{2} \sqrt{\pi} s ω \left(- j + \operatorname{erf}{\left(\frac{\sqrt{2} s ω}{2} \right)}\right) e^{- \frac{s^{2} ω^{2}}{2}}}{2} + 1\)
\(\displaystyle µ\)
\(\displaystyle 2 b^{2}\)
\(\displaystyle \frac{e^{j µ ω}}{b^{2} ω^{2} + 1}\)
\(\displaystyle µ\)
\(\displaystyle σ^{2}\)
\(\displaystyle e^{j µ ω - \frac{σ^{2} ω^{2}}{2}}\)
\(\displaystyle k\)
\(\displaystyle 2 k\)
\(\displaystyle \left(- 2 j ω + 1\right)^{- \frac{k}{2}}\)
\(\displaystyle \frac{k}{λ}\)
\(\displaystyle \frac{k}{λ^{2}}\)
\(\displaystyle \left(- \frac{j ω}{k} + 1\right)^{- k}\)
\(\displaystyle e^{µ + \frac{σ^{2}}{2}}\)
\(\displaystyle \left(e^{σ^{2}} - 1\right) e^{2 µ + σ^{2}}\)
\(\displaystyle \sum_{n=0}^{\infty} \frac{\left(j ω\right)^{n} e^{\frac{n^{2} σ^{2}}{2} + n µ}}{n!}\)
\(\displaystyle \frac{a}{a + b}\)
\(\displaystyle \frac{a b}{\left(a + b\right)^{2} \left(a + b + 1\right)}\)
\(\displaystyle λ \Gamma\left(1 + \frac{1}{k}\right)\)
\(\displaystyle λ^{2} \left(- \Gamma^{2}\left(1 + \frac{1}{k}\right) + \Gamma\left(1 + \frac{2}{k}\right)\right)\)
\(\displaystyle \sum_{n=0}^{\infty} \frac{λ^{n} \left(j ω\right)^{n} \Gamma\left(1 + \frac{n}{k}\right)}{n!}\)