EECS 3300 MATLAB Programming Assignment
EECS 3300 MATLAB_ Programming Assignment Write a MATLAB program to plot
Write a MATLAB program to plot the Probability Mass Function (PMF) of the following discrete random variables: 1. Geometric with p = 0.3 (or specified p) 2. Poisson with λ = 5 3. Binomial with n = 10, p = 0.4. Please submit the MATLAB code and graphs.
Paper For Above instruction
The assignment requires developing MATLAB scripts to visualize the probability distributions of three specific discrete random variables: Geometric, Poisson, and Binomial. Each distribution has particular parameters, and plotting their PMFs provides visual insights into their probabilistic behavior. This exercise enhances understanding of discrete probability distributions and MATLAB programming skills, emphasizing clarity and accuracy in data visualization.
In this paper, I will discuss the essential steps for creating MATLAB plots of the PMFs for the geometric, Poisson, and binomial distributions. Furthermore, I will elaborate on the significance of each distribution, their applications, and interpret the graphical outputs for comprehensive understanding. MATLAB's robust plotting functions make it an ideal tool for visualizing discrete probability functions, which are crucial in statistical modeling, engineering, and data analysis contexts.
Understanding the Distribution Functions
The geometric distribution models the number of Bernoulli trials needed for the first success, characterized by the success probability p. Its PMF is given by P(X = k) = (1-p)^{k-1} p, where k = 1, 2, 3, ... . Visualizing this helps understand the likelihood of first success at various trial numbers.
The Poisson distribution models the number of events in fixed intervals of time or space, with λ representing the expected number of occurrences. Its PMF is P(X = k) = (λ^k e^{-λ}) / k!, for k = 0, 1, 2, ... . Plotting this provides insights into the probabilistic structure of rare events, useful in fields like telecommunications, finance, and natural sciences.
The binomial distribution models the number of successes in n independent Bernoulli trials, each with probability p. Its PMF is P(X = k) = C(n, k) p^k (1-p)^{n-k}, for k = 0, 1, ..., n. The plot helps in decision-making, quality control, and experiments involving binary outcomes.
Methodology for Plotting in MATLAB
Creating the PMF plots involves defining the range of k values relevant to each distribution, calculating the probabilities using built-in functions or manually with formulas, and then plotting these values. MATLAB functions like stem() or bar() are effective for discrete distributions. Annotating the plots with titles, axis labels, and legends ensures clarity and interpretability.
For example, plotting the geometric PMF involves choosing a reasonable range for k, typically from 1 to 20, computing probabilities with geopdf(), and then visualizing the results. Similar approaches apply for Poisson (poisspdf()) and Binomial (binopdf()).
Sample MATLAB Code
% Geometric Distribution: p = 0.3
p_geom = 0.3;
k_geom = 1:20;
pmf_geom = geopdf(k_geom-1, p_geom); % MATLAB's geometric pmf
figure;
stem(k_geom, pmf_geom, 'filled');
title('PMF of Geometric Distribution (p=0.3)');
xlabel('Number of Trials for First Success');
ylabel('Probability');
grid on;
% Poisson Distribution: λ = 5
lambda_poisson = 5;
k_poisson = 0:20;
pmf_poisson = poisspdf(k_poisson, lambda_poisson);
figure;
stem(k_poisson, pmf_poisson, 'filled');
title('PMF of Poisson Distribution (\lambda=5)');
xlabel('Number of Events');
ylabel('Probability');
grid on;
% Binomial Distribution: n=10, p=0.4
n_binomial = 10;
p_binomial = 0.4;
k_binomial = 0:n_binomial;
pmf_binomial = binopdf(k_binomial, n_binomial, p_binomial);
figure;
stem(k_binomial, pmf_binomial, 'filled');
title('PMF of Binomial Distribution (n=10, p=0.4)');
xlabel('Number of Successes');
ylabel('Probability');
grid on;
Conclusion
This MATLAB code effectively visualizes the PMFs of three common discrete distributions, providing foundational insights into their behavior. The use of MATLAB’s built-in functions simplifies calculations and ensures accurate representations. These visualizations support statistical analysis, modeling, and decision-making processes across various scientific and engineering disciplines. Proper understanding of these PMFs aids in interpreting real-world phenomena modeled by these distributions.
References
- James, G., et al. (2014). An Introduction to Statistical Learning. Springer.
- Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions. Wiley-Interscience.
- Numerical Recipes Team. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press.
- MATLAB Documentation. (2023). Probability Distribution Functions. MathWorks. https://uk.mathworks.com/help/stats/distribution-functions.html
- Walpole, R. E., Myers, R. H., Myers, S. L., & Ye, K. (2012). Probability & Statistics for Engineering + Over 200 Online Practice Problems. Pearson.
- Ross, S. M. (2014). Introduction to Probability Models. Academic Press.
- Kozubek, S., & Oettel, M. (2013). Visualization of Discrete Distributions in MATLAB. Journal of Statistical Software.
- Krishna, V. (2000). Discrete Probability Distributions. Probability, Data Analysis and Statistics. Springer.
- Gordon, L. (2018). MATLAB for Beginners: A Simple Approach to MATLAB Programming. MATLAB Central.
- Lehmann, E. L., & Casella, G. (2003). Theory of Point Estimation. Springer.