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

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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') 1 2 3 4 5 6 7 8 9 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') 1 2 3 4 5 6 7 8 9 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 Coeff = ; n = 9, p = 0....
View Full Document

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online