# Does this AnyDice function accurately calculate the number of ogres you make unconcious with three 4th-level castings of Sleep?

Say we have three ogres, and want to put them to sleep as a handful of level 7 casters with the sleep spell. We want to know how many of them, on average, will get put to sleep.

I tried to make an AnyDice function that searches a listing of all of the results of 11d8 for the HP totals that would put to sleep one of the ogres (using the average of 59 HP). Is this AnyDice function accurate to the goal?

output [count {59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88} in 3d(11d8)]

If not, how would I properly create the function?

## The function is correct but can be made simpler

The function makes sense from a theoretical point of view (you are counting the number of times one of the listed numbers appears when doing 11d8 three times) and from practical corroboration from Xirema's answer.

However, it seems to be a particularly taxing function for anydice. Indeed, when changing it to 4 times instead of 3, anydice refused to provide results because it exceeded the maximum execution time.

A simpler and faster way to do the same function would be this anydice function:

output 3d(11d8 > 58)


Which is equivalent, also helps show that your initial thoughts were correct but is much faster and you can also use it for bigger values without anydice complaining.

Naturally this is not as versatile as your specific listing of each possible result but since you only care about results bigger than the creature's HP in this case it may work better.

Alternatively, as proposed by Ilmari Karonen, you could also use, for some more versatility in the results, this function:

output 3d[count {59..88} in 11d8 + 0]


(The + 0 makes AnyDice sum the 11d8 roll before passing it to [count VALUES in SEQUENCE])

• Reason #473 I should really learn how AnyDice actually works..... Good answer. Mar 14, 2019 at 23:05

# This function appears to be correct

The output of the function in Anydice is

Number Probability
0 68.19%
1 27.85%
2 3.79%
3 0.17%

Using an independent method, I was able to calculate [within an acceptable Margin of Error] identical odds:

Number Trials Probability
0 43222444136933962820676160716829 (4.322 * 10^29) 68.1930%
1 17648919028429302571404705792029 (1.765 * 10^29) 27.8415%
2 2402180542167965746972508160028 (2.402 * 10^28) 3.7900%
3 108986303880238935781785600027 (1.090 * 10^27) 0.1720%

So because these two methods appear to have identical outcomes, I'm led to conclude that the function you've provided is correct.

I've posted my methodology here, which contains all of the individual calculations needed to come up with these trial numbers.

• may I ask what your independent method was? Mar 15, 2019 at 3:17
• @Carmeister I have a program that autogenerates a whole lot of tables that eventually are composed together to get the final results. I'm working on a function to spit out the decomposed tables to show the step-by-step process. Watch this space. Mar 15, 2019 at 16:22
• @Carmeister Alright, I put a link in the answer to a chatroom I created solely to contain the methodology. Mar 15, 2019 at 17:30