This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
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: '

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*