Rename year directories to allow natural ordering

This commit is contained in:
2023-12-20 03:57:27 +00:00
parent 0ab1f5ad3a
commit 1f7d812b98
1895 changed files with 0 additions and 7188 deletions

View File

@ -0,0 +1,8 @@
clear;
d = roll_2_dice(10000, 100);
[freq, prop] = tabulate_2_dice(d);
disp(freq);
disp(prop);

View File

@ -0,0 +1,7 @@
function d = roll_2_dice(N, seed)
% function to roll 2 dice and return the combination of each device row in a vector
rng(seed);
% generating two 1 * N vectors of 6 simulated dice rolls and adding them
d = randi([1 6], 1, N) + randi([1 6], 1, N);
end

View File

@ -0,0 +1,14 @@
function [freq, prop] = tabulate_2_dice(d)
% function to calculate the frequency and proportion of each outcome based on a set of dice throws
freq = zeros(1,12);
% looping through all the values in d and incrementing the corresponding counter in freq
for i = d
freq(i) = freq(i) + 1;
end
% looping through each index in prop and calculating the proportion pertaining to that index
prop = zeros(1,12);
for i = [1:12]
prop(i) = freq(i) / sum(freq); % proportion of i is the frequency of i divided by the sum of all freqs
end
end