Can you please solve using MATLAB Binomial distribution is o

Can you please solve using MATLAB

Binomial distribution is one of the widely used probability distributions in engineering practice. It computes the probability of obtaining exactly k successes in n trials, given that the likelihood of success in any trial is p. The distribution is described by P(k) = (_k^n) p^k (1 - p)^k where P(k) represents the probability of finding k successes and (_k^n) = n!/k!(n - k)! Write a function program called prob2 that will use p, n, and k as inputs and returns the probability p(k) = P as the output. Test your function with p = 0.3, n = 10 and k = [1: 10]

Solution

%below is the function u need to write in prob2.m

function P=prob2(p,n,k)
[r,c] = size(k);
for i=1:c
P = ((factorial(n))/(((factorial(n-k(i)))*factorial(k(i)))))*((p^k(i))*((1-p)^(k(i))));
disp(P);
end
end

%In the command window

>> p=0.3;
>> n=10;
>> k = 1:10;
>> prob2(p,n,k)

gives

>> prob2(p,n,k)
2.1000

1.9845

1.1113

0.4084

0.1029

0.0180

0.0022

1.7020e-004

7.9428e-006

1.6680e-007

Can you please solve using MATLAB Binomial distribution is one of the widely used probability distributions in engineering practice. It computes the probability

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site