Lab report

If the risk is high, the reward is high… Why not roll the dice?:

Probability of the two dice roll.

Name: Andrii Iarmolenko

Date:10/08/2024

Abstract:

This laboratory experiment involved writing a simple code to simulate rolling a pair of six-sided dice 100 times, to observe how often each possible sum appeared and compare those results with expected probabilities. The hypothesis was that the sum of 7 would show up most often, based on known probability theory. After recording and analyzing the sums (which range from 2 to 12), the results showed that 7 was the most frequent, occurring about 19% of the time. Other sums also appeared at frequencies that were close to their expected probabilities. Overall, the findings were consistent with what previous studies on dice probability have shown.

Introduction:

            In probability theory, when rolling a pair of six-sided dice, a range of possible sums from 2 to 12 is generated. Each sum has a different chance of occurring, with the sum of 7 being the most common. This experiment aimed to validate these theoretical predictions by simulating 100 rolls of two dice using MATLAB. The objective was to observe the frequency distribution of the sums and compare the results with established probability values. The hypothesis was that the sum of 7 would occur more frequently than any other sum due to the higher number of combinations that result in a 7. This experiment provides an opportunity to test probability theory using computer simulation, avoiding human error in physical dice rolling and enabling quick data collection.

Materials and Methods:

Materials

  • MATLAB software
  • A script to simulate dice rolling
  • Spreadsheet in MATLAB and histocounts function for data analysis and graphing

Methods

  1. Simulate dice rolls by writing a MATLAB script to simulate rolling two six-sided dice 100 times. Each die is represented by a random integer between 1 and 6, corresponding to the faces of a standard die. The script adds the results of the two dice to compute the sum for each roll.
  • Record Data: Capture the sums from all 100 rolls and store them in an array. Use the MATLAB function to count the occurrences of each possible sum, ranging from 2 to 12.
  • Analyze data and plot a histogram graph in MATLAB to visually represent the frequency distribution of the sums. Compare the experimental results with the theoretical probabilities for each sum. The theoretical probability of each sum is calculated based on the number of ways each sum can be rolled.
  • Compare with theoretical probability distribution for the sums, noting that the sum of 7 has the highest likelihood (16.67%), and sums like 2 and 12 have the lowest (2.78%).

Results:

            The results of the MATLAB simulation showed the following frequencies for each sum from 2 to 12:

SumFrequencyPercentage, %
233.0
344.0
41111.0
51111.0
61717.0
71919.0
888.0
999.0
1099.0
1144.0
1255.0

Figure 1. Frequency of Sums in 100 MATLAB Dice Rolls

Figure 2. Number of Sums for Dice Roll Pairs.

Analysis:

            The results of the experiment mostly aligned with theoretical predictions, supporting the hypothesis that the sum of 7 would occur most frequently. The sum of 7 appeared 19% of the time, which closely matches the expected probability of 16.67%. Other sums also followed the predicted trends, with six occurring frequently, while sums like 2 were relatively rare.

However, there were slight deviations from the theoretical probabilities. For example, the sum of 7 occurred slightly more often than expected, and the sum of 8 was slightly underrepresented. These deviations are likely due to the small sample size of 100 rolls, as random fluctuations become less significant with larger datasets.

The findings were consistent when comparing the results to previous studies on dice probability. For instance, one study on dice simulations reported similar frequencies for each sum, particularly the prominence of the sum of 7 (Lucas & Engel, 2010). The MATLAB simulation provided a reliable way to simulate random events and confirm established probability theory.

Citation:

Lukac, S., & Engel, R. (2010). Investigation of Probability Distributions Using Dice Rolling Simulation. Australian Mathematics Teacher66(2), 30–35.

Appendix:

dice roll

clc, clear;
rolls = randi(6, 2, 100);  % Generate dice rolls
rolls_row = rolls’;
sum_pairs = sum(rolls_row, 2);  % Sum each pair of dice rolls

disp(‘ |Dice 1|Dice 2| Sum |’)
disp(‘ ——————–‘)
disp([rolls_row sum_pairs])  % Display the dice rolls and their sums

% Count occurrences of each number for both dice
[counts_dice1, ~] = histcounts(rolls(1, :), 1:7);  % Count for Dice 1
[counts_dice2, ~] = histcounts(rolls(2, :), 1:7);  % Count for Dice 2

% Display counts
disp(‘Number of occurrences for Dice 1:’)
disp(‘    1s    2s    3s    4s    5s    6s’)
disp(counts_dice1)

disp(‘Number of occurrences for Dice 2:’)
disp(‘    1s    2s    3s    4s    5s    6s’)
disp(counts_dice2)

% Count occurrences of each sum (from 2 to 12)
[counts_sums, ~] = histcounts(sum_pairs, 1.5:12.5);  % Count sums of dice pairs

% Display the count of each sum
disp(‘Number of occurrences for each sum (from 2 to 12):’)
disp(‘ sum:2     3     4     5     6     7     8     9    10    11    12’)
disp(counts_sums)

figure(1)
histogram(sum_pairs)
title(‘Numeber of Sums for Dice roll Pairs’)
xlabel(‘Total numbers of sums’)
ylabel(‘Number of occurrences’)
xticks(2:12)

 |Dice 1|Dice 2| Sum |
 ——————–
     5     6    11
     1     6     7
     4     1     5
     2     4     6
     6     6    12
     1     6     7
     6     3     9
     5     1     6
     3     6     9
     5     6    11
     4     1     5
     6     6    12
     5     5    10
     5     3     8
     4     2     6
     5     1     6
     2     1     3
     1     5     6
     5     2     7
     6     1     7
     3     3     6
     5     5    10
     2     3     5
     3     4     7
     5     5    10
     2     5     7
     4     1     5
     1     3     4
     6     3     9
     4     2     6
     5     2     7
     4     5     9
     6     6    12
     4     1     5
     1     2     3
     6     2     8
     5     2     7
     6     3     9
     2     2     4
     4     3     7
     3     5     8
     4     4     8
     6     2     8
     5     5    10
     3     4     7
     1     1     2
     4     5     9
     6     1     7
     4     3     7
     1     3     4
     1     5     6
     2     4     6
     1     4     5
     2     4     6
     5     5    10
     3     1     4
     2     6     8
     1     5     6
     4     6    10
     1     3     4
     1     6     7
     1     5     6
     5     6    11
     1     3     4
     2     5     7
     3     6     9
     2     2     4
     1     1     2
     6     4    10
     4     1     5
     6     4    10
     3     4     7
     3     1     4
     2     1     3
     2     2     4
     3     1     4
     6     6    12
     3     3     6
     3     6     9
     3     1     4
     5     3     8
     2     3     5
     1     1     2
     6     6    12
     4     1     5
     2     3     5
     5     1     6
     1     2     3
     4     5     9
     4     3     7
     4     2     6
     5     2     7
     5     2     7
     3     4     7
     5     1     6
     6     5    11
     3     3     6
     3     2     5
     4     4     8
     5     5    10

Number of occurrences for Dice 1:
    1s    2s    3s    4s    5s    6s
    17    14    16    18    20    15

Number of occurrences for Dice 2:
    1s    2s    3s    4s    5s    6s
    21    16    18    12    17    16

Number of occurrences for each sum (from 2 to 12):
 sum:2     3     4     5     6     7     8     9    10    11    12
         3     4    11    11    17    19     8     9     9     4     5

Published with MATLAB® R2024b