# With a known probability, how can I determine a roll to fit that probability to a population of n?

I'm working on making some homebrew settlement downtime activity, and I'd like to create a table that can provide some various outcomes for a group. So I"m looking for the math that allows to figure this out not a specific answer on this table.

Say I have a settlement of 200 people and I want a method to determine how many of them are considered unskilled laborers and how many are skilled laborers. The overall average of the area might 30% skilled and 70% unskilled labor, but I want a chart to determine what that actually would mean for this specific settlement. I would want to roll, say, a 2d6 once and it would give me an outcome of something like:

$$\\begin{array}{|c|l|} \hline \textbf{Roll Total} & \textbf{Outcome} \\ \hline 2 & \text{high number of unskilled laborers, low number of skilled laborers} \\ 3 & \\ 4 & \\ 5 & \\ 6 & \\ 7 & \text{70% unskilled labor, 30% skilled labor} \\ 8 & \\ 9 & \\ 10 & \\ 11 & \\ 12 & \text{lowest number of unskilled laborers, highest number of skilled laborers} \\ \hline \end{array} \$$

I'm trying to understand the math so I can apply this to masses.

Another example is that around this settlement, there are some areas that are more dangerous than others, like the enchanted forest nearby, but some residents are going to forage there anyways. I'd like to have a group encounter/resolution table then, and though I know that there is a 5% chance of an encounter each day there, how can I apply that en masse to, say, 20 residents that went out there with one roll rather than 20 rolls.

Now say this isn't the only settlement, and so now there are some settlements with a thousand residents and some with a handful. I want some dice rolling to determine outcomes but not for each resident in each settlement individually.

The closest I came to that I could find was this flipping coins a number of times. However there wasn't anything that referred to the specific math so I could do the same kind of thing.

Table 1. Distribution of “tails” within 100 sets of flipping a coin, each set consisting of 6 flips of a coin

$$\\begin{array}{|c|c|} \hline \textbf{Number of tails} & \textbf{% of flip sets} \\ \hline 6 & 2 \\ 5 & 9 \\ 4 & 23 \\ 3 & 32 \\ 2 & 23 \\ 1 & 9 \\ 0 & 2 \\ \hline \end{array} \$$

I recall dealing with something like this in college, but I don't recall the math at all so I'm hoping someone else can point me to what I have forgotten.

• I'm unclear as to what your end goal is for having this information. – NautArch Mar 26 '19 at 18:54
• yes, but what exactly can we do to help? This sounds like it should be very specific to the campaign, and not at all universal, making creation of such a chart quite difficult for us to help with from what I'm understanding, so tell us how exactly you want us to help you – Smart_TJ Mar 26 '19 at 19:23
• For a question like this, it might be better if you solicit help from our RPG.SE Chat Room. It looks like the problems you're trying to solve are too broad or too subjective to fit the Q&A format this site uses. – Xirema Mar 26 '19 at 19:54
• I'm confused by what is the desired use of the settlement table. What is the question you would like that table to provide the answer for? – GcL Mar 26 '19 at 20:03
• @John Great! The reviewers who reopen questions usually don't want to scan through a bunch of the comments, so it will help get this question reopened (and answered) sooner if you edit the question itself so it makes that clearer. – Gandalfmeansme Mar 26 '19 at 20:35

## You're (probably) describing a Binomial Distribution

There are a lot of different ways to go from individual probabilities to the probabilistic behavior of a group. But when the probability of an event is constant (in your second case, 5%), the events are "independent" (which may not be the case here, but we can assume for the sake of simplicity), and you want to know how likely it is that there is a certain number of "successes" in "n" given opportunities for success (in your second case, n=20), then the most common way to describe it is with a "binomial distribution."

I'd recommend looking into this kind of statistical distribution, specifically the Cumulative Distribution Function of a Binomial Distribution. There are some useful tools out there that can help you quickly calculate the "cumulative distribution function" of such a distribution, (the probability you get a given number of successes or fewer) which could help you set probability ranges for certain results. As an example, using the link I just provided, here's a "lower Cumulative Distribution" for a situation where you have 20 trials and each trial has a 5% chance of success (villagers going into the woods).

Again, these percents indicate the probability that you will get "x" or fewer successes. This lets us quickly set up a percentile results table for the number of villagers that have encounters in the woods in a given day.

$$\\begin{array}{|c|l|} \hline \textbf{d100 result} & \textbf{Number of Encounters} \\ \hline 1-35 & \text{0 encounters} \\ 36-73 & \text{1 encounter}\\ 74-92 & \text{2 encounters}\\ 93-98 & \text{3 encounters}\\ 99-100 & \text{4 (or more) encounters}\\ \\ \hline \end{array} \$$

You could roll two d10s (different colors so you knew which was the 10s number and which the 1s number), and get a percentile result from that. For exmaple, if you rolled a 4 for the 10s and a 9 for the 1s, you'd get 49 and conclude there was one encounter that day.

Different probabilities and different "n" values will create different charts. I hope that this gets you started on a useful path.

• @Sycorax Good point! I've added that now. – Gandalfmeansme Mar 27 '19 at 14:15
• Really good stuff thank you @gandalfmeansme this is exactly what I was looking for. – John Mar 28 '19 at 13:12

## It's probably better to just make something up.

The problem with focusing too much on math is that it's easy to end up spending a lot of effort on accurately sampling from a probability distribution that doesn't actually match players' expectations of reality.

In particular, the binomial distribution suggested by Gandalfmeansme accurately models the distribution of the number of successes in $$\n\$$ attempts that each succeed independently of each other with a fixed probability $$\p\$$. However, in real life, attempts are rarely independent and probabilities are rarely fixed.

For example, in your example of a bunch of townspeople visiting a dangerous forest, would you really expect the others not to react if something happens to one of them? (Well, maybe you would, if they all left and returned at the same time, and made sure to stay out of sight and hearing range of each other. But how plausible is that?) And is it really reasonable to assume that the risk of entering the forest is the same every day, or would it be more reasonable to assume that the forest is perfectly safe on most days, except when a pack of wandering predators or bandits or whatever just happen to be nearby.

Now, my point is not that you should adjust and complicate your math to model all these additional aspects of the situation. Rather, what I'm trying to suggest is that, since you know that your mathematical model won't be fully realistic anyway, you should just make up something that is simple and feels reasonable, maths be damned. (And I say this as someone with a degree in applied mathematics.) And then be prepared to tweak things at the table if it feels like you should.

For example, for your dangerous forest, you could e.g. just roll a d20 once a day (in secret, if necessary!) to see if the forest is safe to visit today. If you roll 2 or above (or 3 or above, if you want to make it really dangerous), it's safe and nothing happens. If you roll a one, there's something dangerous lurking in the forest, and anyone who goes there will have to deal with it. Or, if that doesn't feel right, then do something else. But keep it simple.

Similarly, for your town population example, you should first consider how many skilled and unskilled people it makes sense for this particular town to have, and what skills they should have. Is it a farming town, a fishing town or a mining town? (And if so, what do they farm, fish or mine?) Does it lie on major road or a trade route? Does it have industry? Is there a church or a shrine of some sort? Is there a fort or a military camp nearby, and is the town itself walled for defense? Is it the biggest town in the area, and if not, where and how close is the nearest bigger town? Is there anything else in the town or nearby that makes it special? Hot springs? Mysterious caves? Ancient ruins? A wizard's tower?

In any case, no matter what the town is like, it will probably have a certain number of various skilled craftspeople like millers, weavers, shoemakers, potters, coopers, carpenters, smiths, traders, innkeepers, etc. And the number of these people in each town of a given size will be more or less the same, because if a single shoemaker can make and repair enough shoes for the whole town, it makes little sense for there to be two. More likely, if there were two but only enough demand for one, the other would move away to another town that doesn't have its own shoemaker yet.

That is, of course, unless there's extra demand for a particular profession due to some specific reason, like one of those I listed above. A trading town on a busy road probably has more innkeepers than a farming town out in the middle of nowhere. A military town needs blacksmiths, and so probably does a mining town (but they'll mostly work on different things). A town that produces wine will have need of coopers (and/or potters, depending on local traditions and the availability of wood and clay). But everyone still needs shoes, although not every small town necessarily has its own shoemaker — but even if it doesn't, there's probably one working somewhere within a day's travel at most.

So what it you just want to generate a random town? Well, you can start by assuming that there's at least one of each kind of tradesperson that you feel a town of that size should probably have. (And don't worry if you forget some, because if your players ask if the town has, say, a farrier, you can just point them at the stables and say "sure, of course it does!") And then consider what specific trades the town might have extra demand for, and add in a bunch of those. But don't add too many, because in a pre-modern society something like over 90% of the overall population should be farming or fishing or doing something else that directly feeds them (and indirectly feeds all the craftspeople and soldiers and anyone else who doesn't grow or gather their own food).

In the end, basically, your town should have the population make-up that feels right to you. And you probably don't need to plan it all in advance, either; you can just describe the town to your players in broad terms (e.g. "most people here are simple farmers, but there's also an inn that doubles as a general store") and make up the details if and when they come up.

## But I still want a mathy solution!

OK, fine, let's just assume that the binomial distribution is a reasonable approximation to the real situation you want to model. What we want to do, in turn, is approximate the binomial distribution with something that requires fewer dice rolls.

First of, a helpful mathematical result known as the Poisson limit theorem says that, for large $$\n\$$ (and for RPG purposes, we can safely regard $$\n \ge 10\$$ or even $$\n \ge 5\$$ as "large"), the shape of the binomial distribution depends mostly on the expected average number of successful outcomes, which is simply the number of independent attempts $$\n\$$ times the probability $$\p\$$ of a single attempt succeeding.

Now, depending on whether this expected number of successes is (much) less than or greater than one, or approximately equal to one, we have three possible cases:

• If $$\n \cdot p\$$ is much less than one, successes will be rare, and multiple successes even rarer. In this case, you can pretty reasonably just roll 1d100 and treat any result equal to or less than $$\100 \cdot n \cdot p\$$ as a (single) success, and any higher result as no success.

• If $$\n \cdot p\$$ is much greater than one, the binomial distribution looks "bell curve" shaped, and is well approximated by a normal (Gaussian) distribution with mean $$\\mu = n \cdot p\$$ and variance $$\\sigma^2 = n \cdot p \cdot (1-p)\$$. We can in turn approximate this normal distribution with a suitable set of dice rolls:

• For example, we could roll (approximately) $$\n \cdot p\$$ Fudge dice, sum them up and add $$\n \cdot p\$$ to the result.

• If $$\n \cdot p\$$ dice is too many, divide it by $$\10\$$. Roll that many fudge dice, multiply the result by $$\3\$$ ($$\\approx \sqrt{10}\$$) and add $$\n \cdot p\$$ to it.

• If that's still too many dice, divide $$\n \cdot p\$$ by $$\100\$$ instead. Roll that many fudge dice, multiply the result by $$\10\$$ ($$\= \sqrt{100}\$$) and add $$\n \cdot p\$$ to it.

If you don't happen to have any Fudge dice handy, just use normal six-sided dice and subtract the number of 1s and 2s from the number of 5s and 6s.

(This method somewhat underestimates the variance for small $$\p\$$, and may slightly overestimate it for large $$\p\$$, but overall it gives pretty reasonable-looking results. For very small $$\p\$$ and correspondingly large $$\n\$$, flipping $$\n \cdot p\$$ coins and counting the number of heads minus tails would actually give a more accurate variance than using Fudge dice. But for moderate values of $$\p\$$, as in your examples, the somewhat lower variance of the Fudge dice is actually a feature. And they tend to produce a smoother distribution, too.)

• If $$\n \cdot p\$$ is approximately one (say, between 0.2 and 5), both of the previous methods can produce poor results.* In this case, we can make use of the Poisson limit theorem mentioned above, and approximate the binomial distribution we want with another binomial distribution that has a smaller $$\n\$$ but a correspondingly higher $$\p\$$.

For example, instead of rolling 20d20 and counting 1s to find out how many out of 20 residents encounter something in the forest, you can instead roll 6d6 or even 4d4 and get approximately the same distribution.

More generally, you could e.g. roll $$\X\$$d20 and count the number of results less than or equal to $$\n \cdot p \cdot 20 \mathbin/ X\$$. Of course, for this approximation to make sense, this threshold should be at least 1 and less than 20. (In fact, it should preferably be 10 or less.)

BTW, regardless of which method you use, if the success probability $$\p\$$ is greater than 50%, you should swap the outcomes so that $$\p\$$ becomes less than 50% before applying any of the approximations above.

*) Depending on the exact values of $$\n\$$ and $$\p\$$ and the level of accuracy you want, the first two methods above can sometimes be OK even for $$\n \cdot p\$$ close to one. In particular, the Fudge dice method works decently well even for small expected success counts, as long as $$\n \cdot p\$$ happens to be (close to) an integer, but exhibits rounding bias if it's not.

Ps. Here's an AnyDice script for testing the approximations given above. You can tweak the values of $$\n\$$ and $$\p\$$ (which the script expects to be a percentage, i.e. multiplied by 100) to see how the various approximations compare to the exact binomial distribution.

While the script applies some checks on the value of $$\n \cdot p\$$ to avoid displaying approximations that make absolutely no sense, the checks are deliberately rather loose, as it's potentially interesting to see how the approximations start to break down at the edges of their validity region.

For example, for your forest encounter example (with $$\n = 20\$$ and $$\p = 0.05\$$), the script shows the following possible approximations:

You can see that all the approximations shown in the plot get the expected number of encounters ($$\n \cdot p = 1\$$) correct, while all but the d100 method (which isn't really applicable for such high values of $$\n \cdot p\$$ anyway) also produce a standard deviation that's at least in the right ballpark. But in this case, the "count rolls ≤ 4 in 5d20" method is a lot better than the others in getting the shape of the distribution right.

Meanwhile, for your town population example (with $$\n = 200\$$ and $$\p = 0.3\$$), the output looks like this:

In this case, only the Fudge dice approximations are shown, as they're the only ones suitable for such high expectation values ($$\n \cdot p = 60\$$). The first approximation is clearly very close, but requires rolling 60 Fudge dice — which is better than, say, 200d20, but still kind of impractical. The second approximation only requires 6 rolls instead of 60, but does have the disadvantage of always producing a result that is a multiple of 3 (which is why the graph looks funny). If you wanted to smooth it out, you could always roll one extra Fudge die and add it to the result without multiplying it by 3.

• +1 for "make it up to match player expectations". Kind of like how iTunes made its Shuffle less random so that it would feel more random. I'd give you another +1 for going on to answer the questions as asked, if I could. – keithcurtis Mar 28 '19 at 17:14
• @keithcurtis you can always bounty for "another +1"... =) – nitsua60 Mar 29 '19 at 1:41