{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hmk4sol - num2str(r Using this code we get the following...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
Matlab Exercises This code implements the binomial probability given by The code: function p=binom(n,x,r) % binomial distribution % n = Number of trials % x = Exact number of successes % p = Probability of success in a single trial m1 = log(factorial(n)); m2 = log(factorial(x)); m3 = log(factorial(n-x)); r = exp(m1 - m2 - m3 + x*log(r) + (n-x)*log(1-r)); % we display the answer (the instruction 'num2str' transforms a number into a string), str = ['Probability of ' num2str(x) ' successes in ' ... num2str(n) ' trials: '
Background image of page 3

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

View Full Document Right Arrow Icon