{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MATLAB+Examples+of+PMF+for+Binomial+distribution+with+different+parameter+p

# MATLAB+Examples+of+PMF+for+Binomial+distribution+with+different+parameter+p

This preview shows pages 1–2. Sign up to view the full content.

1. MATLAB Examples of PMF for Binomial distribution with different parameter p Coeff = []; n = 9, p = 0.75; % setting parameters for the Binomial distribution for k = 0:1:n, Coeff = [Coeff factorial(n)/factorial(k)/factorial(n-k)]; end B_n_p = Coeff .* p.^(0:n) .* (1-p).^(n-(0:n)); stem(0:n, B_n_p); axis([0 n 0 1]) title('PMF of Binomial B(n,p) with n=9, p=0.75'); ylabel('B(n,p)'); xlabel('k') 0 1 2 3 4 5 6 7 8 9 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 PMF of Binomial B(n,p) with n=9, p=0.75 B(n,p) k Coeff = []; n = 9, p = 0.25; % setting parameters for the Binomial distribution for k = 0:1:n, Coeff = [Coeff factorial(n)/factorial(k)/factorial(n-k)]; end B_n_p = Coeff .* p.^(0:n) .* (1-p).^(n-(0:n)); stem(0:n, B_n_p); axis([0 n 0 1]) title('PMF of Binomial B(n,p) with n=9, p=0.25'); ylabel('B(n,p)'); xlabel('k') 0 1 2 3 4 5 6 7 8 9 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 PMF of Binomial B(n,p) with n=9, p=0.25 B(n,p) k Coeff = []; n = 9, p = 0.5; % setting parameters for the Binomial distribution for k = 0:1:n, Coeff = [Coeff factorial(n)/factorial(k)/factorial(n-k)]; end B_n_p = Coeff .* p.^(0:n) .* (1-p).^(n-(0:n)); stem(0:n, B_n_p); axis([0 n 0 1]) title('PMF of Binomial B(n,p) with n=9, p=0.5'); ylabel('B(n,p)'); xlabel('k') 0 1 2 3 4 5 6 7 8

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}