Equivalent DnD dice roll for a rational probability

Fun
Verfolgen


Equivalent DnD dice roll for a rational probability

Matt Tearle am 9 Feb. 2025 um 15:01
Letzte Aktivität Antwort von Hans Scharler am 11 Feb. 2025 um 18:11

I got thoroughly nerd-sniped by this xkcd, leading me to wonder if you can use MATLAB to figure out the dice roll for any given (rational) probability. Well, obviously you can. The question is how. Answer: lots of permutation calculations and convolutions.
In the original xkcd, the situation described by the player has a probability of 2/9. Looking up the plot, row 2 column 9, shows that you need 16 or greater on (from the legend) 1d4+3d6, just as claimed.
If you missed the bit about convolutions, this is a super-neat trick
[v,c] = dicedist([4 6 6 6]);
bar(v,c)
% Probability distribution of dice given by d
function [vals,counts] = dicedist(d)
% d is a vector of number of sides
n = numel(d); % number of dice
% Use convolution to count the number of ways to get each roll value
counts = 1;
for k = 1:n
counts = conv(counts,ones(1,d(k)));
end
% Possible values range from n to sum(d)
maxtot = sum(d);
vals = n:maxtot;
end
Anmelden, um teilzunehmen
Hans Scharler
Hans Scharler am 11 Feb. 2025 um 18:11
So, you are saying, when it matters, you roll a 1?

Tags

Noch keine Tags eingegeben.

Go to top of page