Skip to content

How do you handle weighted dice in your algorithm, concretely? #219

Answered by HighDiceRoller
ogregoire asked this question in Q&A
Discussion options

You must be logged in to vote

Glad to get your question! The short answer is the first modified line should have pow(w, n) rather than w and the other modified line pow(w, k) instead of w.


The long answer: suppose that, rather than computing comb(n, k) * pow(w, k) for a single choice of $n$ and $k$, we want to compute it for all $0 \leq k \leq n \leq N$ for some $N$. (Indeed, the dice pool algorithm will visit every one of these coefficients at some point.) For the pure binomial case ($w=1$) it's well-known that we can do this using Pascal's triangle, where each entry is the sum of the two entries above it:

If you like, you can think of this in terms of vectors instead of individual elements:

One copy (blue) stays …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by HighDiceRoller
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #214 on February 10, 2025 00:56.