Hmk4sol - num2str(r Using this code we get the following answers What is the probability of getting three heads in five tosses of a fair coin

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 DocumentRight 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 DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: num2str(r)]; Using this code, we get the following answers: What is the probability of getting three heads in five tosses of a fair coin? Number of trials: 5 Exact number of successes: 3 Probability of success: .5 And the Matlab response is Probability of 3 successes in 5 trials: 0.3125 What is the probability that in five rolls of a fair die, a number 1 appears twice? Number of trials: 5 Exact number of successes: 2 Probability of success: 1/6 And the response is Probability of 2 successes in 5 trials: 0.16075...
View Full Document

This note was uploaded on 11/29/2010 for the course ECE 302 taught by Professor Gelfand during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 4

Hmk4sol - num2str(r Using this code we get the following answers What is the probability of getting three heads in five tosses of a fair coin

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online