4
\$\begingroup\$

I'm trying to figure out how to create an odd dice curve - specifically, odd when plotting between an axis of average result versus amount of dice (so xd6 gets 3.5 for x=1, 7 for x=2 and so on).

But, I can't figure out how (if?) anydice can let me control what the plot axis will be, or how to work around it anyway. Any pointers?

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Is the summary view what you want? If not, I'm not quite sure what you're asking for. \$\endgroup\$ Feb 11, 2022 at 20:53
  • \$\begingroup\$ @IlmariKaronen Alas, no. I want to loop through several values of X (say, 1-10), calculate the average of a roll based on X (say, Xd6) and then plot the relationship between X and the average of the rolls. \$\endgroup\$ Feb 11, 2022 at 21:29
  • 2
    \$\begingroup\$ That's exactly the "mean" curve in what Ilmari posted. \$\endgroup\$ Feb 12, 2022 at 2:44
  • \$\begingroup\$ @HighDiceRoller I am evidently blind, cause I knew that. Thanks, you two! \$\endgroup\$ Feb 12, 2022 at 11:29
  • \$\begingroup\$ @IlmariKaronen can you make this an answer so I can choose it? If convenient, add the instruction to hit 'graph view' for completeness' sake, and if there's a way to hide the other plots (particularly maximum) for clarity, that'll be even better! \$\endgroup\$ Feb 12, 2022 at 11:29

2 Answers 2

4
\$\begingroup\$

You can output each of your rolls with an appropriate title, as in:

loop N over {1..10} {
  output Nd6 named "[N]d6"
} 

and then switch to the summary view. Here, the uppermost chart (titled "mean") shows the average of each roll your program outputs:

AnyDice screenshot showing the "mean" chart in summary mode for the program above, with the "Summary" button circled in red.  The chart is a horizontal bar chart with the labels from "1d6" to "10d6", and with values increasing linearly from 3.50 for "1d6" to 35.00 for "10d6".

If you prefer, the summary output can also be viewed in graph mode, with the black line showing the mean:

AnyDice screenshot showing the summary data for the program above in graph view mode, with the "Graph" and "Summary" buttons circled in red.  The graph is a line graph with a caption in the top right corner.  The X axis is labelled from "1d6" on the left to "10d6" on the right.  The Y axis is labelled from 0.00 on the botton to 60.00 on the top, in increments of 15.00.  There are four lines on the graph: a straight black line captioned "mean", rising from 3.50 on the left to 35.00 on the right, a slightly curved orange line captioned "deviation" (rising from 1.70 on the left to 5.40 on the right, approximately proportional to the square root of the mean), a light blue straight line captioned "maximum" (rising from 6.00 to 60.00), and a green straight line captioned "minimum" (rising from 1.00 to 10.00).  The green "minimum" line overlaps and partly obscures the orange "deviation" line.

Unfortunately, there does not seem to be any way (short of writing a userscript or something like that to manipulate the AnyDice UI) to hide the "deviation", "minimum" and "maximum" outputs in summary mode and to show only the mean. This can be a problem especially in graph view mode, since for some distributions (such as those involving "exploding dice") the maximum can be significantly higher than the mean, and thus make the mean line hug the bottom of the chart when graphed.

However, one possible (though somewhat time-consuming) workaround is to switch to the "export" view mode, copy-paste the raw numeric CSV data from there to a spreadsheet (such as Excel, LibreOffice Calc or Google Sheets) and graph it there.

\$\endgroup\$
1
  • \$\begingroup\$ An excellent and thorough response, thanks! That is exactly why I wanted to cut out maximum, and this is a fine way to do it if it comes to that! \$\endgroup\$ Feb 12, 2022 at 13:58
0
\$\begingroup\$

You do not actually need anydice to do this.

Beside Ilmari Karonen's answer, you can consider the math behind this kind of dice rolling.

We know that a d6 follow a discrete uniform distribution, whose expected value \${\rm E}[d6]\$ is 3.5. The expected value operator is linear, meaning that the expected value of the sum of the outcomes of two dice \$d_1, \, d_2\$ is the sum of the expected values of the two outcomes:

$$ {\rm E}[d_1 +d_2] = {\rm E}[d_1]+{\rm E}[d_2] $$

and it can be generalized to \$X\$ dice.

Then, you can directly compute the expected value of Xd6, which reads as $$ {\rm E}[Xd6] = X\cdot{\rm E}[d6] = X\cdot3.5 $$

Hence, you can plot the dependence of the expected value on the number of d6 rolled, by considering the function

$$ y = 3.5x $$

in the Cartesian Plane. Down below you can find an example written in Python.

import numpy as np
import matplotlib.pyplot as plt

average = np.zeros(10)
for x in np.arange(1,11,1):
  average[x-1] = x*3.5 
  
plt.plot(np.arange(1,11,1),average,'o--')
plt.xlabel("Number of Dice")
plt.ylabel("Expected value")

You can generalize this approach: for example you can plot the variance or the standard deviation of Xd6, or the expected value of Xd12 or other kind of dice.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .