1. Write a MATLAB function binomialPMF that takes as input the scalar quantities
ID: 3405419 • Letter: 1
Question
1. Write a MATLAB function binomialPMF that takes as input the scalar quantities n and p and returns a vector containing the binomial distribution with parameters n and p, i.e px (k) = (.)pk(1-p)"-k, k= 0,1, , n. Create a single figure containing the following three binomial distributions: (a) n = 30 and p = 0.5 plotted as a solid red line with legend description "n=30 and p=05"; (b) n = 30 and p = 0.7 as a solid green line with legend description "n=30 and p=0.7", and (c) n = 60 and p = 0.5 as a solid blue line with legend description "n=60 and p=0.5" Label the x-axis with "k", y-axis with "p.X(k)", and use the title "Binomial Probability Mas Function"Explanation / Answer
Definitely it is the question of statistic and probability.
We have a function named "binord" whose syntax:
F = binornd(n,p)
F = binornd(n,p,a,b,...)
F = binornd(n,p,[a,b,...])
F = binornd(n,p) generates random numbers from binomial distribution having the parameters, number of trials n and probability of success p for each trial. Now these n, p can be vectors or matrices or arrays (multidimensional) that have the same size of F.
F = binornd(n,p,a,b,...) or F = binornd(n,p,[a,b,...]) generates an a-by-b-by-... array which contains random numbers from the binomial distribution having the inputs n and p. n and p are scalers or arrays of same size of F.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.