05 Probability

What do we need to know from probability theory in this course?

Learning outcomes

After this practice session, the student

  • understands the concept of conditional probability, can compute its value from the known probabilities of experiment outcomes (elementary events);
  • understands the concept of discrete random variable and can compute its expected value;
  • can approximately solve simple probability-related tasks with computer simulation.

Program

  • Q/A Reversi, etc.
  • Discussion of the last bonus quiz solution, $\alpha-\beta$ pruning
  • Random variable, expected value
  • Probability and simulation
  • Bonus quiz: conditional probability

Exercise I / Solving together

Random variable, mean value

In certain board game, the dice are rolled in the following way:

  • We roll the die a first time.
  • If we get an odd number, we roll a second time.
  • The value of such a roll is denoted as H and it is the highest number that was rolled (i.e. the even number that was rolled on the first roll, or the greater of the numbers from both rolls if an odd number was rolled the first time).

What is the mean (expected) value of such a roll? Try to solve first theoretically and then by simulation.

Solution via theory

Instructions:

  1. First, define the space $\cal S$ of elementary events (outcomes of the experiment).
  2. Determine the probabilities of these elementary events. Are they all the same? What should their sum be? Is this condition met?
  3. Define the random variable (r.v.) $H$, i.e. determine what real value $H(s)$ is assigned to each elementary event $s \in \cal S$.
  4. What is the support of r.v. $H$? (that is, which real values will have a non-zero probability?)
  5. Define the probability distribution of r.v. $H$, i.e. determine the value of the function $p_H(x)$ for all values of $x$.
  6. Determine the expected value $E(H)$ of r.v. $H$.

Solution via simulation

Instructions:

  1. Create a function that will return a single value of $H$ according to the above rules.
  2. Find out the results of many such rolls and calculate their average.
  3. Try to run the script many times and observe differences in the estimated $E(X)$.

Exercise II: Probability and simulation

If you have time, try to solve other probability problems by simulation, e.g:

  • The probability for a family to have two daughters, one of whom is born on a Monday (see the 3rd bonus quiz question).
  • A problem about the probability that a student will catch the bus if he arrives at the bus stop anytime between 6:58 and 7:02, while the bus leaves anytime between 7:00 and 7:03.
    • “anytime” here means that you are to assume a uniform distribution.
    • How would the simulation change if the equal distribution of the student's arrival time at the bus stop and bus departure time were changed, for example, to a normal distribution?

Bonus quiz

  • Calculate some probabilities about siblings
  • submit your solution to BRUTE lab05quiz, deadline in BRUTE
  • format: text file, photo of your solution on paper, pdf - what is convenient for you
  • solution will be discussed on the next lab
  • 0.5 points
  • Students with their family name starting from A to K (included) have to solve and upload subject A , while students with family name from L to Z have to solve and upload subject B.

Homework

  • Submit the elaborated bonus quiz to BRUTE, task lab05quiz, deadline in BRUTE.
  • Continue working on the 2nd mandatory assignment, Reversi. Deadline in BRUTE.
courses/be5b33kui/labs/weekly/week_05.txt · Last modified: 2026/03/16 16:00 by xposik