2. Create a Matlab function called binomial(x,n.p) with arguments for x (number
ID: 3184881 • Letter: 2
Question
2. Create a Matlab function called binomial(x,n.p) with arguments for x (number of successes), n (total number of trials), and p (probability of success) that determines the cumulative probability [F(x)] of a binomial distribution. In oter words, binomial should output the sum of the following series from k-otokex Here The term (n)can be solved using the folowing formula (the symbol represents the factorial function-Google if you don't know what it means!): n! kt (n - k)! You may use the factorial function in Matlab to help you do this. As an example: binomial( 3,1 0, 0.5) F(3:1 0,05) = 0.172 You can use the preceding result to check your binomial function. There is also a built- in function in Matlab (search for it) that does the same thing,so you can use that to check your answer, too. The total code can be easily done in 7 lines of codeExplanation / Answer
function d=Binomil(x,n,p)
sum=0;
for k=1:x
sum=sum+(factorial(n)/(factorial(k)*factorial(n-k)))*p^k*(1-p)^(n-k);
end
d=sum;
end
Binomil(3,10,0.5)
ans =
0.1709
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.