<<

The Triangular Function

Each of the six faces of a fair die is equally likely to face up after the die is rolled. This means that any of the values on the face of a die, 1 to 6, is equally likely to be the outcome of a roll, which is equivalent to saying that the probability of getting a number betweeen 1 and 6 (inclusive) is 1/6, and zero otherwise. With this in mind, complete Table 1 for the case when two fair dice are rolled.

Table 1: Probabilities for two fair dice. Sum Unique Combinations Number Probability 1 2 3 4 5 6 7 8 9 10 11 12 13

Note that the sum of the probabilities is 1 (100%) as it should be if all possibilities are considered. Plotting the probabilities in Table 1 against the associated sums produces a distribution [see Figure 1] known as a triangular probability distribution func- tion. In this case, the distribution is symmetric around the center, and therefore forms the shape of an isosceles triangle, with half the base (referred to as the half-width, a, here 6) times the height (6/36 = 1/6) giving the area of 1 (equal to the total probability). In general, a symmetric triangular probability distri- bution has a mean at the middle of the distribution, a half-width a, and a height 1/a. Imagine you roll two fair dice thirty six (36) times, and the results perfectly match ”theoretical” expectations listed in Table 1. Histogram these “per- fect” results (how many sums of 1 do you expect, how many sums of 2, etc). Be sure to label the axes and give the histogram a title. Set the abscissa (x-axis) limits 0 - 14. The symmetry of this distribution implies that the mean, , and are all the same: the center of the distribution. For an arbitrary distribution, the mean can be found by, for N discrete values, xi,

1 Figure 1: Probability distribution for two fair dice. Note the symmetry of the distribution (an isosceles triangle). The connected dots define a probability distribution function (pdf) for the roll of two fair dice. This kind of pdf is known as a triangular pdf. The symmetry implies that the center of the distribution is also the mean. Also shown is the half-width, a.

P x x¯ = i i (1) N while for a continuous distribution, where the pdf is represented by f(x), Z ∞ x¯ = xf(x)dx (2) −∞ Check that the three ways of determining the mean of the “per- fect” triangular distribution that you histogrammed all give the same answer. Note that for this distribution, x is the sum of two dice faces, and the pdf is

 1 36 (x − 1), 1 ≤ x ≤ 7  1 f(x) = 36 (13 − x), 7 < x ≤ 13 (3)  0 Otherwise so that the integral becomes

1 Z 7 Z 13  x¯ = x(x − 1)dx + x(13 − x)dx (4) 36 1 7

2 The spread of a distribution around its mean is given by the or, in the same units as the mean, the square root of the variance, also known as the standard uncertainty. For discrete values,

P (x − x¯)2 s2 = i i (5) N − 1 or for a continuous distribution, Z ∞ Z ∞ s2 = (x − x¯)2f(x)dx = x2f(x)dx − x¯2 (6) −∞ −∞ √ is the variance, and the standard uncertainty is s = s2. The generic form of a triangular probability distribution function with mean x¯ and full width 2a is,

 1 a2 [x − (¯x − a)], (¯x − a) ≤ x ≤ x¯  1 f(x) = a2 [(¯x + a) − x), x¯ < x ≤ (¯x + a) (7)  0 Otherwise Plugging Equation 7 into Equation 6 gives the general form of the variance and standard uncertainty of a triangular pdf:

a2 s2 = (8) triangle 6 a striangle = √ (9) 6 Check that the variance and stardard uncertainty of the “perfect” triangular distribution that you histogrammed is the same whether you use Equation 5 or Equation 6. Roll a pair of dice 36 times, plot a histogram of the results, calcu- late the mean and standard uncertainty of the resulting distribution. How does your experiment compare to the ideal distribution you plot- ted previously? Justify your response quantitatively. Be sure to title and label the axes of your histogram. Set the abscissa (x-axis) limits 0 - 14. If you can’t get hold of pair of dice, you can simulate a pair of dice by adding a pair of random numbers, each of which can choose a value 1 to 6 with equal likelihood. In python, this can be done, with the pylab module, with rolls = randint(1, 7, 36) + randint(1, 7, 36) hist(rolls) xlim(0, 14) mean(rolls) std(rolls) where the arguments of randint are the lower bound (inclusive), upper bound (not inclusive), number of samples, respectivley.

3