SF1911: Statistik för bioteknik Föreläsning 3. TK 3.11.2017 TK Matematisk statistik 3.11.2017 1 / 53
Probability: What is it? Probability is a number between 0 and 1 that predicts the (relative) frequency of an event. a p. 302 a John Ringo: Fundamental Genetics, Cambridge University Press, 2004, TK Matematisk statistik 3.11.2017 2 / 53
Probability = 1 a certain event, Probability = 1/2 equal chance (perfectly random), Probability =0 an impossible event TK Matematisk statistik 3.11.2017 3 / 53
Probability: What is it? The empirical probability: the histogram of the matchbox data in previous lectures. We assume that nothing changes radically (in the industrial production of matches). The probability of the event 50 the number of matches in a box 53 is taken as the relative frequency of 50 the number of matches in a box 53. TK Matematisk statistik 3.11.2017 4 / 53
Frekvenstabell: grupperade data Table: Frekvenstabell för antal tändstickor i tändsticksaskar. Klass Absolut Relativ frekvens frekvens x n(x) f X (x) = n(x)/35 48 2 0.057 49 4 0.114 50 6 0.171 51 9 0.257 52 6 0.171 53 7 0.20 54 0 0.0 55 1 0.029 S:a 35 100.0 TK Matematisk statistik 3.11.2017 5 / 53
Probability:empirical probability Assume that there is no systematic change in the future industrial production of matchboxes. Then the probability of the event 50 the number of matches in a box 53 is f X (50) + f X (51) + f X (52) + f X (53) = 0.171 + 0.257 + 0.171 + 0.20 0.80 Use the current relative frequencies as probability. p i 0.3 0.2 0.1 48 49 50 51 52 53 54 55 TK Matematisk statistik 3.11.2017 6 / 53
Probability:empirical probability We write now the probability of the event 50 the number of matches in a box 53 sannolikheten för händelsen as P (50 the number of matches in a box 53 ) = 0.80 Then, of course, the probability of a simple event like for example the number of matches in a box = 53 is its relative frequency P ( the number of matches in a box = 53 ) = f X (3) = 0.20 TK Matematisk statistik 3.11.2017 7 / 53
Probability: empirical probability The probability of the event 50 the number of matches in a box 53 P (50 the number of matches in a box 53 ) = 0.80 This is a probability based on observed data. If we assume that nothing changes, that if we receive a new matchbox and check the number of matches in it, there is 80% chance of the event 50 the number of matches 53 occurring. TK Matematisk statistik 3.11.2017 8 / 53
Probability: empirical probability The probability P (50 the number of matches in a box 53 ) = 0.80 was based on checking 35 boxes. The relative frequencies will change if we observe new boxes, but they will stabilize. Here 0.80 is our prediction of the frequency of this event. TK Matematisk statistik 3.11.2017 9 / 53
Probability: theoretical TK Matematisk statistik 3.11.2017 10 / 53
Probability: classical probability To each of the four sides of a tetrahedron there is assigned one of the letters a,t,c,g. All letters are used. We call this the DNA die. We toss the die in the air and note the side that it falls on. a t c g TK Matematisk statistik 3.11.2017 11 / 53
Probability: classical What is the probability of the event a in one toss? All the sides of the tetrahedron are of equal area, and the tetrahedron is balanced. We can freely exchange the letters between the sides and yet we have the same die. The situation is such that we assign the probabilities P(a) = P(t) = P(c) = P(g) = 1 4 to the four possible outcomes of a single toss. In other words, all outcomes of the toss of the die are equally likely. TK Matematisk statistik 3.11.2017 12 / 53
Probability: classical P(a) = P(t) = P(c) = P(g) = 1 4 Then 1/4 is the prediction of the frequency of any nucleotide in a long sequence of tosses of the die. This was based on reasoning about symmetry, not on observed data. TK Matematisk statistik 3.11.2017 13 / 53
Probability: classical We toss the die in the air several times and note the side that side that it falls on. Clearly we can thus produce a random DNA sequence. Such a sequence would seem to lack value for biotechnology. Disregarding that for the moment, we might ask what is the probability of observing the sequence caagt in five tosses of the die, or what is the probability of the event caagt in five tosses. One answer to this question is found in the sequel. a t c g TK Matematisk statistik 3.11.2017 14 / 53
Den klassiska sannolikhetsdefinitionen: det allmänna fallet Antag att vi har m möjliga elementära utfall ω 1,..., ω m, var och en med samma sannolikhet att inträffa, dvs P(ω k ) = 1 m k = 1,..., m. Betrakta en händelse A, A {ω 1,..., ω m }. Antag att A innehåller g (gynnsamma) utfall. Då gäller P(A) = g m. TK Matematisk statistik 3.11.2017 15 / 53
Slumpförsök: tärningskast och P(A) Låt oss säga att vi kastar en tärning, och är intresserade av händelsen {vi får en sexa}. Om det är en hederlig tärning, är den sannolikheten 1 6. Symboliskt kan vi skriva A = {vi får en sexa} och P(A) = 1 6. TK Matematisk statistik 3.11.2017 16 / 53
SANNOLIKHETSKALKYL: allmänna räkneregler för P(A) TK Matematisk statistik 3.11.2017 17 / 53
Slumpförsök (random trial) Allmänna beteckningar Mängden av alla utfall, eller resultat, kallar vi utfallsrummet och betecknar det med Ω. En händelse A är en mängd av utfall, dvs en delmängd av Ω, A Ω. TK Matematisk statistik 3.11.2017 18 / 53
Valet av utfallsrum beror på situationen eller den fråga vi vill studera. Exempel: Ω= de fem miljoner tändsticksaskarna producerade under en given dag. Ω= de 35 miljoner tändsticksaskarna producerade under en sjudagars period. TK Matematisk statistik 3.11.2017 19 / 53
Venndiagram Definition Mängden av alla utfall, eller resultat, kallar vi utfallsrummet och betecknar det med Ω. Ω TK Matematisk statistik 3.11.2017 20 / 53
Venndiagram Definition En händelse A är en mängd av utfall, dvs en delmängd av Ω, A Ω. Ω Α TK Matematisk statistik 3.11.2017 21 / 53
Venndiagram; två händelser Ω Α Β TK Matematisk statistik 3.11.2017 22 / 53
Händelser A B A och B definierade på samma försök. Här är några exempel på vad som kan inträffa, och hur vi matematiskt kan uttrycka detta: Exempel A inträffar, A A och B inträffar eller A snitt B inträffar, A B Ω = {etta, tvåa, trea, fyra, femma, sexa } A = udda antal ögon = {etta, trea, femma }. B = {femma, sexa }, A B = {femma }. TK Matematisk statistik 3.11.2017 23 / 53
Venndiagram A B Ω Β 000 111 000 111 0000 1111 0000 1111 00000 11111 00000 11111 00000 11111 00000 11111 000000 111111 000000 111111 000000 111111 000000 111111 000000 111111 000000 111111 000000 111111 00000 11111 0000 1111 000 111 000 111 Α Α B TK Matematisk statistik 3.11.2017 24 / 53
Händelser A B A eller B inträffar eller A union B inträffar, A B Obs! A B betyder att minst en av A eller B inträffar, så A B kan mycket väl inträffa. I matematik betyder eller och/eller! TK Matematisk statistik 3.11.2017 25 / 53
Händelser A B A B betyder att minst en av A eller B inträffar Exempel Ω = {etta, tvåa, trea, fyra, femma, sexa } A = udda antal ögon = {etta, trea, femma }. B = {femma, sexa }, A B = {etta, trea, femma, sexa }. TK Matematisk statistik 3.11.2017 26 / 53
Venndiagram A B Ω Α Β A B TK Matematisk statistik 3.11.2017 27 / 53
Händelsen A c A inträffar inte, A c. (A c ) c = A. Exempel Kast av en tärning Ω = {etta, tvåa, trea, fyra, femma, sexa } A = udda antal ögon = {etta, trea, femma }. A c = { tvåa, fyra, sexa }=jämnt antal ögon. TK Matematisk statistik 3.11.2017 28 / 53
Exempel Ω = {a, t, c, g} A = {a, t}. A c = {c, g}. TK Matematisk statistik 3.11.2017 29 / 53
Venndiagram A c A A c Ω TK Matematisk statistik 3.11.2017 30 / 53
tomma mängden Om A och B utesluter varandra, dvs. omöjligt kan inträffa samtidigt, så säger vi att A och B är disjunkta eller oförenliga, dvs. A B = där är tomma mängden eller den omöjliga händelsen. Ω c = TK Matematisk statistik 3.11.2017 31 / 53
tomma mängden A och B utesluter varandra, dvs. omöjligt kan inträffa samtidigt. Exempel Ω = {etta, tvåa, trea, fyra, femma, sexa } A = {etta, trea, femma }. B = { fyra, sexa }, A B =. TK Matematisk statistik 3.11.2017 32 / 53
Venndiagram; A B = Ω Α Β TK Matematisk statistik 3.11.2017 33 / 53
De Morgans regler Sats A (B C ) = (A B) (A C ) A (B C ) = (A B) (A C ) Sats (A B) c = A c B c TK Matematisk statistik 3.11.2017 34 / 53
De Morgans regler (A B) c = A c B c Exempel Ω = {etta, tvåa, trea, fyra, femma, sexa } A = {etta, trea, femma }. B = {femma, sexa }, A B = { femma } (A B) c = {etta, tvåa, trea, fyra, sexa } A c B c = {tvåa, fyra, sexa } {etta, tvåa, trea, fyra } = {etta, tvåa, trea, fyra, sexa } TK Matematisk statistik 3.11.2017 35 / 53
X = {x 1, x 2,..., x n } med n datapunkter i Ω. n(x) = antalet gånger x förekommer i X. Den relativa frekvensen är f X (x) = n(x) n. Observera att f X (x) = 0 om x inte återfinns bland X. Om A Ω, så är P X (A) = de olika f X (x) x A den relativa frekvensen av A eller den empiriska sannolikheten för A (m.a.p. X ). där f X (x) beräknats utifrån X. TK Matematisk statistik 3.11.2017 36 / 53
Då gäller följande: a) 0 P X (A) 1. b) P X (X ) = 1. c) Om A och B inte innehåller gemensamma värden (är disjunkta), så är P X (A B) = P X (A) + P X (B). TK Matematisk statistik 3.11.2017 37 / 53
Vi tar de ovanstående egenskaperna hos empirisk sannolikhet som allmänna räkneregler: En sannolikhet P är en funktion av händelser, sådan att: (a) 0 P(A) 1; (b) P(Ω) = 1 (c) om A och B är disjunkta händelser, d.v.s. A B =, så gäller P(A B) = P(A) + P(B). (a) och (b) kan ses som en kalibrering så att P stämmer med intuitionen från relativa frekvenser. TK Matematisk statistik 3.11.2017 38 / 53
Räkneregler för sannolikhetskalkyl (1) Sats P(A c ) = 1 P(A). Bevis. Ett mycket formellt bevis, för att illustrera kalkyler enligt (a)-(c) ovan: Eftersom A och A c disjunkta och A A c = Ω, så fås enligt (c) och (b) ovan P(A) + P(A c ) = P(Ω) = 1 P(A c ) = 1 P(A). Då gäller P( ) = 0. TK Matematisk statistik 3.11.2017 39 / 53
Regler för sannolikhetskalkyl (2) Sats P(A B) = P(A) + P(B) P(A B). Bevis. Satsen följer med hjälp av Venn-diagram, och observationen att P(A) + P(B) mäter A B två gånger. TK Matematisk statistik 3.11.2017 40 / 53
Regler för sannolikhetskalkyl (3) Om A B =, så fås P(A B) = P( ) = 0, dvs. P(A B) = P(A) + P(B). Detta följer av det ovan visade Sats P(A B) = P(A) + P(B) P(A B). TK Matematisk statistik 3.11.2017 41 / 53
Example The DNA die again, the events A 1 = {a, t}, A 2 = {c} are mutually exclusive. Also the events {a} and {t} are mutually exclusive. Thus the additive law together with the theoretical probability model from the above gives P(A 1 ) = P({a, t}) = P (a or t) = P(a) + P(t) = 1 4 + 1 4 = 1 2 The additive law gives also P (A 1 A 2 ) = P(A 1 ) + P(A 2 ) = 1 2 + 1 4 = 3 4 TK Matematisk statistik 3.11.2017 42 / 53
In the figure we have 14 (abstract) peas: nine have white flowers, five have red flowers, six have yellow pods, eight have green pods. We compute with classical probability. TK Matematisk statistik 3.11.2017 43 / 53
What is P(green pods or white flowers )? TK Matematisk statistik 3.11.2017 44 / 53
green pods or white flowers means green pods or white flowers or both it is wrong to add to the 8 peas with green pods the 9 peas with white flowers, because then you have counted 5 of the peas twice. P(green pods or white flowers ) = 12 14 = 6 7 TK Matematisk statistik 3.11.2017 45 / 53
In the example above this gives P (A B) = P(A) + P(B) P(A B) P(green pods or white flowers ) = P(green pods ) + P( white flowers ) P(green pods and white flowers ) = 8 14 + 9 14 5 14 = 12 14 = 6 7 TK Matematisk statistik 3.11.2017 46 / 53
Probability: independent events We say that A and B are independent events if P (A B) = P(A) P(B). TK Matematisk statistik 3.11.2017 47 / 53
Example I en stor population har 4% celiaki, d.v.s gluteinintolerans. Du plockar på måfå och oberoende av varandra två individer, a och b. Låt oss beteckna utfallen så att t.ex (1, 0) svarar mot att individ a har celiaki och b har inte o.s.v.. Då är utfallsrummet Vi har att P(1) = 0.04, P(0) = 0.96 Ω = {(0, 0), (1, 0), (0, 1), (1, 1)} (0,1) (0,0) B (1,1) A (1,0) TK Matematisk statistik 3.11.2017 48 / 53
Example a) Vad är sannolikheten för att både a och b har celiaki? Svar: Vi sätter A = {(1, 0), (1, 1)} (d.v.s alla utfallen, där a har celiaki) och B = {(0, 1), (1, 1)} (d.v.s alla utfallen, där b har celiaki). Den sökta sannolikheten är p.g.a. oberoendet P(A B) = P((1, 1)) = P(1)P(1) = 0.04 0.04 = 0.0016. TK Matematisk statistik 3.11.2017 49 / 53
Example continued P(1) = 0.04, P(0) = 0.96 Ω = {(0, 0), (1, 0), (0, 1), (1, 1)} b) Vad är sannolikheten för att minst en har celiaki? Svar 1: Den sökta sannolikheten är P(A B) = P(A) + P(B) P(A B). P(A) = P((1, 0)) + P((1, 1)) = P(1)P(0) + P(1)P(1) = 0.04 0.96 + 0.0016 = 0.04 Vi har att P(B) = P(A). Den sökta sannolikheten är p.g.a. oberoendet P(A B) = 0.04 + 0.04 0.0016 = 0.0784. TK Matematisk statistik 3.11.2017 50 / 53
Example continued Svar 2: (A B) c = A c B c = {(0, 0)}. Den sökta sannolikheten är P(A B) = 1 P((0, 0)) = 1 0.96 0.96 = 0.0784. TK Matematisk statistik 3.11.2017 51 / 53
Example continued c) Ingen har celiaki? Svar: P((0, 0)) = P(0)P(0) = 0.9216 eller P((0, 0)) = 1 P(A B) = 1 0.0784 = 0.9216. d) Precis en av a och b har celiaki? Svar: Med mängdoperationer svarar händelsen precis en av a och b har celiaki mot (A B c ) (A c B), en union av två disjunkta händelser. Detta ger P((0, 1)) + P((1, 0)) = P(0)P(1) + P(1)P(0) = 2 0.04 0.96 = 0.0768 TK Matematisk statistik 3.11.2017 52 / 53
Probability: classical The probability of the event caagt in five tosses. We assume independent tosses of the DNA die. P(caagt) = P(c) P(a) P(a) P(g) P(t) = 1 4 1 4 1 4 1 4 1 4 = 1 4 5 = 0.0009. a t c g TK Matematisk statistik 3.11.2017 53 / 53