Counting and Probability - Computational Concepts in Biological Sciences - Lecture Note, Lecture notes of Computer Science

Main points of this lecture are: Counting, Average Case Behavior, Function of Input, Product Rule, Example Subsets, Inductive Step, Enumerating Permutations, Sum Rule, Exclusion Principle, Number of Passwords, Tree Diagrams, Tree Example

Typology: Lecture notes

2012/2013

Uploaded on 04/23/2013

ashwini
ashwini 🇮🇳

4.5

(18)

167 documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
0 means the event will never occur.
1 means the event always occurs.
0.5 means the event occurs roughly 1/2 of the time.
The probability of a event is a number between 0 and 1
that determines "how likely" the event is to occur.
3 to 1 against means the probability of the event is
1/4 and the probability of the event not happening is
3/4
10 to 1 for means the probability of the event
happening is 10 out of 11 times (10/11) while the
probability of the event not happening is 1/11.
You might have encountered probability stated as odds:
Probability
Fri day, October 22, 2010
Probability Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Counting and Probability - Computational Concepts in Biological Sciences - Lecture Note and more Lecture notes Computer Science in PDF only on Docsity!

0 means the event will never occur. 1 means the event always occurs. 0.5 means the event occurs roughly 1/2 of the time. The probability of a event is a number between 0 and 1 that determines "how likely" the event is to occur. 3 to 1 against means the probability of the event is 1/4 and the probability of the event not happening is 3/ 10 to 1 for means the probability of the event happening is 10 out of 11 times (10/11) while the probability of the event not happening is 1/11. You might have encountered probability stated as odds: Probability Friday, October 22, 2010 9:18 PM Docsity.com

(We're repeating concepts from the last lecture) There is a close relationship between probability and counting Counting and probability Wednesday, October 27, 2010 3:13 PM Docsity.com

Docsity.com

E.g., height and weight of people. E.g., flips of a coin. E.g., 5-card poker hands. An experiment is a situation in which you measure something. E.g., one person's height and weight. E.g., flipping a coin once. E.g., the contents of one poker hand. A trial of an experiment measures one situation E.g., heights and weights of all people. E.g., flipping a coin an unlimited number of times. E.g., all possible poker hands. A population is a set of possible outcomes for the experiment: E.g., heights and weights of 10 known people. E.g., flipping a coin 10 times. E.g., 10 poker hands. A sample is some subset of a population describe populations through samples. describe experiments through trials. Our goals Experiments, populations, and samples Monday, October 25, 2010 11:50 AM Docsity.com

We might roll a die, e.g., 100 times. What can we predict about the rolls? number of ways it can roll "six" = ---------------------------------------------------- total number of outcomes of one roll coming up with a "six" is 1/6 =. Theoretical probability 100 rolls might be: 2,2,4,6,4,5, 1 ,5,5,2,5, 1 ,5,4,6,5,2,4, 1 ,4, 5,2,5,2,4,5,4,3,2,2,5,3, 1 ,4,6,6, 1 ,3, 1 ,4, 3, 1 ,2, 1 ,3,4,2, 1 ,3,4,3,4,6,5,2,5, 1 ,6,3, 1 , 2, 1 ,2,5,4,2, 1 ,5,4,6,3,6,5,5,2,2,2,6,3,2, 5,6,3,2,2,4, 1 ,6, 1 ,2,4,2,4, 1 ,3,2,6, 1 ,6, In this there are 17 ones, so the empirical probability of rolling a one is 17/100 =. Empirical probability: Note: empirical probability almost never equals theoretical probability, unless the sample is large. Example: rolling a die Friday, October 22, 2010 9:23 PM Docsity.com

rand(1) generates a number between 0 and 1. rand(10) generates a float number between 0 and 10 (not including 10.0) int(rand(10)) generates an integer between 0 and 9. In Perl, the rand function generates a random number. int(rand(6))+1 is a random number between 1 and 6. so Simulating dice Monday, October 25, 2010 12:16 PM Docsity.com

Every run is different.

Empirical probabilities vary. 12:39 PM

Example: throwing two dice:

. "$howmany/36 = $prob\n";

make 100 rolls of two dice.

for ($i=0; $i<100; $i++) { $roll = int(rand(6))+1 + int(rand(6))+1; $stuff{$roll}++; # tabulate what happened }

show statistics

foreach my $s (2..12) { print "there are $stuff{$s} rolls of $s out of 100 \n"; $prob = $stuff{$s}/100; print " empirical probability of $s is $prob\n";

theoretical probability

$howmany=$s-1 if $s<=7; $howmany=13-$s if $s>7; $prob = $howmany/ 36; $prob = int($prob*100+0.5)/100; print " theoretical probability of $s is " } Pasted from Two dice Monday, October 25, 2010 12:41 PM Docsity.com

  • there are 17 rolls of 1 out of
    • empirical probability of 1 is 0.
    • theoretical probability of 1 is 1/
  • there are 24 rolls of 2 out of
    • empirical probability of 2 is 0.
    • theoretical probability of 2 is 1/
  • there are 12 rolls of 3 out of
    • empirical probability of 3 is 0.
    • theoretical probability of 3 is 1/
  • there are 17 rolls of 4 out of
    • empirical probability of 4 is 0.
    • theoretical probability of 4 is 1/
  • there are 17 rolls of 5 out of
    • empirical probability of 5 is 0.
    • theoretical probability of 5 is 1/
  • there are 13 rolls of 6 out of
    • empirical probability of 6 is 0.
    • theoretical probability of 6 is 1/
  • Monday, October 25, What happens:
  • there are 0 rolls of 2 out of
    • empirical probability of 2 is
    • theoretical probability of 2 is 1/36 = 0.
  • there are 1 rolls of 3 out of
    • empirical probability of 3 is 0.
    • theoretical probability of 3 is 2/36 = 0.
  • there are 12 rolls of 4 out of
    • empirical probability of 4 is 0.
    • theoretical probability of 4 is 3/36 = 0.
  • there are 10 rolls of 5 out of
    • empirical probability of 5 is 0.
    • theoretical probability of 5 is 4/36 = 0.
  • there are 12 rolls of 6 out of
    • empirical probability of 6 is 0.
    • theoretical probability of 6 is 5/36 = 0.
  • there are 17 rolls of 7 out of
    • empirical probability of 7 is 0.
    • theoretical probability of 7 is 6/36 = 0.
  • there are 17 rolls of 8 out of
    • empirical probability of 8 is 0.
    • theoretical probability of 8 is 5/36 = 0.
  • there are 11 rolls of 9 out of
    • empirical probability of 9 is 0.
    • theoretical probability of 9 is 4/36 = 0.
  • there are 9 rolls of 10 out of
    • empirical probability of 10 is 0.
  • Tuesday, October 26, What this does:
    • empirical probability of 10 is 0.
    • theoretical probability of 10 is 3/36 = 0.
  • there are 9 rolls of 11 out of
    • empirical probability of 11 is 0.
    • theoretical probability of 11 is 2/36 = 0.
  • there are 2 rolls of 12 out of
    • empirical probability of 12 is 0.
    • theoretical probability of 12 is 1/36 = 0.

roll 2 in 1 way (1+1) roll 3 in 2 ways (1+2, 2+1) roll 4 in 3 ways (1+3, 2+2, 3+1) roll 5 in 4 ways (1+4, 2+3, 3+2, 4+1) roll 6 in 5 ways (1+5, 2+4, 3+3, 4+2, 5+1) roll 7 in 6 ways (1+6, 2+5, 3+4, 4+3, 5+2, 6+1) roll 8 in 5 ways (2+6, 3+5, 4+4, 5+3, 6+2) roll 9 in 4 ways (3+6, 4+5, 5+4, 6+3) roll 10 in 3 ways (4+6, 5+5, 6+4) roll 11 in 2 ways (5+6, 6+5) roll 12 in 1 ways (6+6) one can So the theoretical probability of rolling a 7 is 6/36 = 1/6. 7 or 11 has a probability of 8/36 ("craps") Theoretical analysis of two dice Tuesday, October 26, 2010 3:37 PM Docsity.com

Repeat throws of two dice 100, 1000, 10000, 100000 times. What happens? We'll demonstrate the law of large numbers sunfire13{couch}113: perl large.perl after 100 trials: roll 2 3 4 5 6 7 8 9 10 11 12 got 0 4 10 9 15 17 17 14 7 2 5 expect 3 6 8 11 14 17 14 11 8 6 3 after 1000 trials: roll 2 3 4 5 6 7 8 9 10 11 12 got 19 63 92 109 130 170 140 104 85 51 37 expect 28 56 83 111 139 167 139 111 83 56 28 after 10000 trials: roll 2 3 4 5 6 7 8 9 10 11 12 got 273 574 838 1106 1359 1688 1430 1071 838 527 296 expect 278 556 833 1111 1389 1667 1389 1111 833 556 278 after 100000 trials: roll 2 3 4 5 6 7 8 9 10 11 12 got 2735 5565 8326 11212 13915 16553 13926 11009 8430 5552 2777 expect 2778 5556 8333 11111 13889 16667 13889 11111 8333 5556 2778 See http://www.cs.tufts.edu/comp/14/examples/Probability/large.perl As the number of rolls increases, the number of times each number appears approaches what theory suggests. Demonstrating the law of large numbers Monday, October 25, 2010 12:44 PM Docsity.com

If p(E) is the probability of E, and we "try" E n times, then we "expect" that E will be true np(E) times. Reason: p(E) = #successes/#trials = #successes/n, so np(E)=#successes. What we expect Tuesday, October 26, 2010 3:44 PM Docsity.com

Example: We draw one marble from an urn containing 3 red marbles, 1 blue, and 1 green. What is the probability that it is red? Answer: All outcomes S = {R 1 ,R 2 ,R 3 ,G,B} Desirable outcomes E = {R 1 ,R 2 ,R 3 } p(E)=|E|/|S| = 3/5. Example Tuesday, October 26, 2010 3:50 PM Docsity.com

Example: we draw three balls from the same urn. What is the probability that all are red? Answer: There are C(5,3) possible drawings, and C(3,3)= drawing that we desire, so the probability is |E|/|S|= 1/C(5,3)=1/10. Example Tuesday, October 26, 2010 3:52 PM Docsity.com