# What is the correct terminology for repeating groups of coin flips multiple times in a simulation?

I previously posted a question that is causing a lot of confusion because my terminology is incorrect. I decided to post this question to ensure I am starting my problem with the correct terminology.

I will introduce the problem below with (hopefully) neutral terminology

I am running a simulation for coin tosses (or flips). In the simulation, I am grouping together a number of tosses and counting the heads within the group. I would repeat this process multiple times to get counts of heads for multiple groups.

Example: If I have a group size of 5 and repeat the process three times:

• Group 1: HTTTT = 1
• Group 2: THHHT = 3
• Group 3: HHHHT = 4

What is the accepted terminology ...

1. for a group of tosses where the number of heads are counted in the group? Note: previously, I was referring to this as a sample.
2. for the repeating multiple groups of tosses? Note: previously, I was referring to this as a repetition

It would be good if answers could provide authoritive references to the provided definitions.

In your simulation you want to tally up the number of successes (heads) for a series of 5 independent Bernoulli trials from 3 realization (or draws, or observations).

In R this can be done using the rbinom(n, size, prob) function, where n is the number of observations, size is the number of trials and prob the probability of success in each trial. See also here for the function reference (I am sure this is similar in other programming languages as well).

The tallied number of successes for 5 trials can then be calculated as (assuming a fair coin):

> set.seed(123)
> rbinom(3, 5, .5)
[1] 2 3 2


In this case, we have 2 successes (first observation), 3 successes (second observation), 2 successes (third observation).

So Group 1, 2, 3 are observations with 5 trials in each observation.

Here's an illustration of a Galton Board that will make it much clearer what the differences between trials and observations are:

Each ball's path represents one observation (red arrows) passing through 6 left/right decisions or six trials (blue triangles) eventually ending up in one of the bins. The exact probability ($$Pr$$) of landing in one of the bins can be calculated using the binomial probability mass function $$Pr(X = k) = {n \choose k}p^k(1 - p)^{n-k},$$ where $$X$$ represents a random variable, $$k$$ the number of successes (e.g. bounce left), $$n$$ the number trials, and $$p$$ the probability of the outcome of each trial.

In R you can use the dbinom() function to calculate the exact probabilities of falling in each of the bins (from left to right and assuming $$p=0.5$$):

dbinom(6, 6, .5)
#[1] 0.015625
dbinom(5, 6, .5)
#[1] 0.09375
dbinom(4, 6, .5)
#[1] 0.234375
dbinom(3, 6, .5)
#[1] 0.3125
dbinom(2, 6, .5)
#[1] 0.234375
dbinom(1, 6, .5)
#[1] 0.09375
dbinom(0, 6, .5)
#[1] 0.015625


Or through simulation (in this case 100,000 observations and 6 trials):

bounces <- rbinom(100000, 6, .5)
mean(bounces == 6)
#[1] 0.01554
mean(bounces == 5)
#[1] 0.09325
mean(bounces == 4)
#[1] 0.23468
mean(bounces == 3)
#[1] 0.31349
mean(bounces == 2)
#[1] 0.23486
mean(bounces == 1)
#[1] 0.09287
mean(bounces == 0)
#[1] 0.01531

• @ChrisSnow I added another illustration which should make the distinction between observations and trials pretty clear now. – Stefan Jan 31 '19 at 21:03

I understand your confusion. Things become more clear once you think in terms of random variables, outcome sets, and realizations/observations of your random process/variable.

Flipping a coin

A random variable is a function mapping outcomes of a random experiment to numbers. In the case of flipping a coin, we can define a random variable X, to take value 1 when the random variable takes value H, and take value 0 when the random variable takes the value T.

In this case there are only 2 possible outcomes: H or T. The set of all possible outcomes is referred to as the outcome set or sample space. In the case of flipping a coin, the outcome set consists of only 2 outcomes {H,T}.

Now that we have a random variable and the outcome set defined, we can repeat the random experiment of flipping one coin. Let's do it 3 times and observe the realizations of the random process. You may have obtained H on the first flip, T on the second, and H on the third. Your random variable, which assigns numbers to each outcome as per the above rule, will thus take on values 1,0, and 1 respectively. You now have a sample of three observations for the random variable X. A random variable that takes on only 2 values happens to have a special name - a Bernoulli variable.

Flipping 5 coins

Now let's look at a completely different random experiment - flipping 5 coins and counting the number of Heads. In this case, we can define a random variable Y to stand for the number of Heads observed in 5 tosses of a coin. The random experiment here consists of flipping 5 coins. There are 2^5=32 possible outcomes for this experiment, but only 5 possible outcomes for the random variable Y, {0,1,2,3,4,5}. Remember that our random variable Y maps outcomes of the experiment of flipping 5 coins to numbers (count of number of Heads). This mapping is described in the figure below.

You have repeated this random experiment 3 times and obtained: HTTTT, THHHT, and HHHHT. These outcomes of the random experiment map to the following values for the random variable Y: 1, 3, and 4. You now have a sample of three observations for the random variable Y. Such a variable, which counts the number of successes (i.e. Heads) in n repeated Bernoulli trials has a special name - a Binomial variable.

I hope this helps.