====== - #1 Event and probability ====== Let us start with a simple experiment by rolling a normal six-faced dice on a completely flat ground. {{:probability:dice_5.gif|}} The outcome can be one, two, three, four, five (like in the picture), or six. If we roll the dice, one of these six outcomes always appears, i.e. every result of the dice roll can be found in the list. And each one of these outcomes excludes the others, e. g., if we roll a five, we could not get in the same time two or six or any other of the listed outcomes (we have only one dice and it shows five). Outcomes of an experiment/process with random results having such properties are called **elementary events**. Thus, for a normal six-faced dice roll, one, two, three, four, five, and six are elementary events. Note, that one and the same experiment/process can have many different sets of elementary events depending on what is wanted to measure. For example, let us have two deserts: desert 1 and desert 2. And we are not able to choose which one to eat, however, one must be chosen. If we happened to have the same six-faced dice, and we want to use it for choosing between the deserts, we may define elementary events of the dice roll just odd (meaning dessert 1) and even (meaning dessert 2). These are also elementary event of a six-faced dice roll, since with every roll one of these two outcomes always appears. And the outcome of the roll can be in the same time either odd or even, i.e., the outcomes exclude each other. Bring an example of a set of outcomes for the dice roll, which can not be used as elementary events. ++Answer| E.g.\\ outcome $1:=$ "the result is multiples of $3$" and\\ outcome $2:=$ "the result is multiples of $2$".\\ In such a case, by rolling $1$ or $5$, the result does not belong into any of these outcome, as if by rolling a dice we have no result at all. And by rolling $6$, we have in the same time both of the outcomes for the result, since $6$ is multiple of $2$ and also of $3$. ++ Let us denote by $\Omega$ a set of elementary events of some experiment/process with random outcomes. In our example, we fix $\Omega=\{1,2,3,4,5,6\}$. What is $\Omega$ in the case of * tossing a 2-sided coin; ++Answer| $\Omega=\{\text{heads},\text{tails}\}$++ * picking a card from a standard pack; ++Answer| E.g. $\Omega$ is the pack of $52$ cards++ * picking a point from the unit interval, $[0, 1]$. ++Answer| $\Omega=[0, 1]$++ A subset $A$ of $\Omega$ is called an **event**. Thus, an event is any fact, which may occur as a result of an experiment/process. It consists of elementary events. An elementary event is the "smallest" event possible. For example, $A:=\text{"we roll a five"}$ is an event (it is also an elementary event), and $B:=\text{"the outcome is multiple of 3"}$ is an event consisting of two elementary events (i.e. the value is either $3$ or $6$). The event $B$ is not an elementary event. Bring some examples of events concerning: * tossing a coin; ++Answer| E.g. $A:=\text{"we toss tails"}$++ * picking a card from a standard pack; ++Answer| E.g. $A:=\text{"we pick a face card"}$++ * the weather tomorrow; ++Answer| E.g. $A:=\text{"tomorrow it rains"}$++ * the security of a system. ++Answer| E.g. $A:=\text{"the attacker logs into the system without having been authorized"}$++ Let us have an algorithm, where $x$ is evaluated by rolling a dice:\\ $x\leftarrow\{1,2,3,4,5,6\}$\\ if $2$ divides $x$ return $0$\\ if $3$ divides $x$ return $0$\\ return $1$.\\ Which events give the output $0$? ++Answer| The output $0$ is given by events $\text{"2 divides}\ x \text{"}$ and $\text{"3 divides}\ x \text{"}$. ++ Which events give the output $1$? ++Answer| The output $1$ is given by the event $\text{"2 and 3 do not divide}\ x \text{"}$. ++ Describe the events in terms of elementary events. ++Answer| $\text{"2 divides}\ x \text{"}=\{2, 4, 6\}$, $\text{"3 divides}\ x \text{"}=\{3, 6\}$, $\text{"2 and 3 do not divide}\ x \text{"}=\{1, 5\}$++ In the beginning of an experiment/process with random outcomes, we do not know what will be the result. However, we can describe the result by listing all the elementary events (if there is finite set of them) and assigning to every elementary event a probability. A **probability** is a numerical indicator between $0$ and $1$ showing how likely an event is to happen. Probability $0$ means that the event will never happen, and probability $1$ means that the event will happen for sure. For example, the probability of the event $A:=\text{"we roll a seven"}$ is $0$ (denoted: $\text{Pr}[A]=0$) for a normal __six__-faced dice. And if $A:=\text{"we roll a number less than or equal to 6"}$, then $\text{Pr}[A]=1$, since one of the elementary events $1$, $2$, $3$, $4$, $5$, $6$ happens always, if the dice is rolled. For any experiment/process with random outcomes, the sum of probabilities of all the elementary events is always $1$. This property can be used for calculating probability of some event. For example, the table below shows the probabilities of the states of machines in a factory, and we want to know what is the missing probability. ^State of machines ^Probability ^ |Available for use, being used| | |Available for use, not in use| 0,09 | |Broken down | 0,03 | By noticing that "available for use, being used", "available for use, not in use", "broken down" define all the elementary events, the missing probability $\text{Pr}[\text{"available for use, being used"}]=1-0,09-0,03=0,88$. If the probability of machines being available for use is $0,92$, then what is the probability of machines being broken down? ++Answer| $\text{Pr}[\text{"machines are broken down"}]=1-0,92=0,08$++ What is the probability that exploit fails? {{:probability:hakker_1.png|}} ++Answer| $\text{Pr}[\text{"exploit fails"}]=1-0,1-0,52=0,38$++ Now, let us find the probabilities of the elementary events of our dice roll. Let's start by simply rolling the dice and counting how many times we obtain each elementary event. {{url>http://mathwiki.cs.ut.ee/illustrations/dice/diceroll.html 220px}} The quotient $\frac{\text{count of ones (as event count)}}{\text{number of rolles}}$ describes how likely we obtain $1$ in dice roll, and estimates the probability $\text{Pr}[A]$, where $A:=\text{"we roll a one"}$. The same hold for the other elementary events. As you can see from the table above (NB! the number of rolls must be quite big), all the elementary events must be with equal probabilities. By taking into account that the probabilities are all equal, there are $6$ of them, and the sum of probabilities of the elementary events is always $1$, we obtain for the dice roll ^ $A$ | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | ^ $\text{Pr}[A]$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | Such a table (elementary events with probabilities) is called a **probability distribution** of an experiment/process (in our case probability distribution of the dice roll). It describes the result of an experiment/process with random outcomes. If the number of elementary events is finite and they are equally likely (i.e. with equal probabilities), then the probability of an event $A$ is $$\text{Pr[A]}=\frac{\text{the number of elementary events in}\ A}{\text{the number all elementary events}}$$ It is called the formula of classical probability. Thus indeed, $P[\text{"we roll a one"}]=\frac{1}{6}$. And, for example, $P[\text{"the outcome is odd"}]=\frac{3}{6}=\frac{1}{2}$ since the event consists of $3$ elementary events: $1$, $3$, and $5$. Assign probabilities to the following events: * obtaining a "Queen" by taking a card at random from a full pack of $52$ playing cards; ++Answer| There are $4$ Queens in the pack, so $\text{Pr}[\text{"obtaining a Queen"}]=\frac{4}{52}=\frac{1}{13}$++ * obtaining a red sweets by taking a sweets at random from a packet of sweets containing $18$ red sweets, $12$ green sweets, and $10$ yellow sweets; ++Answer| The total number of sweets in the packet is $40$ and $18$ are red, so $\text{Pr}[\text{"obtaining a red sweets"}]=\frac{18}{40}=\frac{9}{20}$++ * choosing an even number at random form numbers $1$ to $11$. ++Answer| There are $5$ even numbers from $1$ to $11$, thus $\text{Pr}[\text{"choosing an even number"}]=\frac{5}{11}$++ In order to understand fully the assumption "elementary events are equally likely" in the formula of classical probability, let us replace the six on the dice with another five ($\Omega=\{1,2,3,4,5\}$). Then common sense tells us that $5$ should occur two times more often then other outcomes (the dice has two fives and all the other outcomes just one time). Thus, all the elementary events are not equally likely. If we still try to use the formula of classical probability we obtain $\text{Pr}[\text{"we roll a five"}]=\frac{1}{5}$. However, the correct probability distribution for such a dice is ^ $A$ | $1$ | $2$ | $3$ | $4$ | $5$ | ^ $\text{Pr}[A]$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $\frac{2}{6}$ | The result is obtained by noticing that the dice has 6 different sides which are equally likely. Thus, the event $\text{"we roll a five"}$ means two sides out of six. Bob has $5$ working video cards and $2$ non working one on his shelf. He does not know which are which, so he asks 3 friend (in order to be sure), what is the probability of getting a non working one by just taking one form the shelf? A classmate has agreed to buy a working one and Bob wants to put minimum amount of effort into the deal. Mary says: "It is $\frac{1}{2}$ because the video card is either working or non working". Dan says: "It is $\frac{2}{5}$ because there are $5$ working video card and $2$ non working". Alice says: "It is $\frac{2}{7}$ because there are $7$ video cards and $2$ are non working". Which of Bob's friends is correct? What mistakes make the ones who are not correct? ++Answer| Alice++ What is the probability of choosing randomly the letter "O" from the following words: * SCHOOL ++Answer| The experiment in this case has not equally likely outcomes - the letter "O" occurs 2 times more often the other letters, so $\text{Pr}[\text{"we obtain O"}]=\frac{2}{6}=\frac{1}{3}$. You can think here, that the word "school" consist of 6 equally likely boxes. Two of the boxes contain the letter "O".++ * LAPTOP ++Answer| The experiment in this case has not equally likely outcomes - the letter "T" occurs 2 times more often the other letters, so $\text{Pr}[\text{"we obtain O"}]=\frac{1}{6}$++ * RING ++Answer| There is no "O" in the letter, so $\text{Pr}[\text{"we obtain O"}]=0$++ [[probability:02_multiple_event_probability|2. Probability of two events]]\\