# Session 2 - Modelling¶

## Exercise 1: Bertrand’s Box¶

Consider the following problem (known as the Bertrand’s box paradox).

There are three boxes:

• a box containing two gold coins,
• a box containing two silver coins,
• a box containing one gold coin and a silver coin.

We first select a box at random, and then we pick a coin at random from this box. If this coin is gold, what is the probability that the second coin is also gold?

Model and solve this problem.

% %

## Exercise 2: character sequences¶

We have a process that generates random sequences consisting of the characters a, b, and c. These characters have probability 0.4, 0.2 and 0.1, respectively. With probability 0.3 the sequence ends.

1. What is the probability of the sequence a, b, a?
2. What is the probability that a sequence of length 4 is generated?
3. What is the probability that a sequence of length 4 has a b in the second position?
% seq(N, ['\$']) :- .... seq(N, [H|T]) :- ... N1 is N + 1, seq(N1, T). seq(S) :- seq(0, S). ... %