Equivalent DnD dice roll for a rational probability

Fun
Suivre


Equivalent DnD dice roll for a rational probability

Matt Tearle le 9 Fév 2025 à 15:01
Dernière activité Réponse par Hans Scharler le 11 Fév 2025 à 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
Connectez-vous pour participer
Hans Scharler
Hans Scharler le 11 Fév 2025 à 18:11
So, you are saying, when it matters, you roll a 1?

Tags

Aucun tag saisi pour le moment.

Go to top of page