Tutorials › AP Statistics › Simulating with randInt on a Calculator

Estimating probability by simulation · Tutorial 206 of 1000

Simulating with randInt on a Calculator

Use calculator-generated integers to model birthday groups, identify matching outcomes, and estimate a probability with relative frequency.

Beginner 9 min read

What You'll Learn

  • Use randInt(1,6,n) to generate the birthdays in one simulated group.
  • Distinguish the number of people in a trial from the number of trials.
  • Decide consistently whether a group contains a matching birthday.
  • Use randInt(0,9) with rejection to model six equally likely birthday labels.
  • Record trial outcomes and calculate their relative frequency.
  • Explain why repeats are allowed within a birthday group.

Use Calculator Integers to Simulate Birthday Groups

In What Is a Probability Simulation and Setting Up a Simulation Model, you learned to define a trial, its possible outcomes, and the event of interest. In Using a Random Digit Table, you applied fixed reading rules to generate outcomes. A TI-84 can generate those chance outcomes for you: its randInt command produces random integers in a specified range.

To keep the example manageable, imagine a calendar with only six possible birthdays, labeled 1 through 6. A trial consists of four people, each assigned a birthday. The event of interest is that at least two people have the same birthday. A trial is a match if any birthday label occurs more than once in that group.

Definition: In this birthday simulation, one trial is a group of four people with birthdays independently selected from labels 1 through 6. The event occurs if at least two of the four labels match. Repeated labels are allowed because different people can have the same birthday.

The six labels are a simplified model, not a claim about real birthdays. The model assumes each of the six dates is equally likely for each person, and that one person’s assigned birthday does not affect another person’s. These assumptions define the chance process the simulation imitates.

Generate One Group with randInt(1,6,n)

On a TI-84, the command randInt(lower, upper, number of values) generates the requested number of integers, including both endpoints. Thus, randInt(1,6,4) produces four integers from 1 through 6. Those four values are the birthdays for one trial. The number 4 here is the number of people in the group; it is not the number of simulated groups.

$$ \text{One trial} = \text{randInt}(1,6,4) = \text{four birthday labels from 1 through 6} $$

The calculator displays a list of four values. Check that list for a repeated label. It does not matter which people have the matching birthdays or whether a label occurs two or more times: any repeat means the event occurred. Then run the command again for a new group. Start each new group with the full set of six possible birthdays; do not remove labels that appeared in an earlier trial.

Some TI-84 models or software versions may display the command slightly differently, but the input and meaning are the same. Use the calculator’s MATH menu and probability submenu to select randInt(, then enter the lower endpoint, upper endpoint, and count. For a group of four, enter 1, 6, and 4 in that order.

Worked Example: Decide Whether One Calculator-Generated Group Has a Match

Suppose the calculator returns the list \(\{2,5,2,6\}\) after entering randInt(1,6,4). Determine whether the birthday event occurs.

Read the list as one trial: The four labels represent four people’s birthdays: 2, 5, 2, and 6.

Check for a repeat: Label 2 appears twice. Therefore, at least two people share a birthday, so the event occurs in this trial.

Record one “yes” for this group. The two appearances of label 2 are not an error or a value to reject. They represent two different people who have the same birthday.

Generate Several Trials and Record Outcomes

A single group shows how the command works, but one simulated group cannot provide a stable estimate of the event’s probability. To estimate it, repeat the same trial many times and record whether the event occurs in each group. Keep the group size, birthday labels, and matching rule unchanged from trial to trial.

The outcome you count is the group, not each person and not each repeated birthday. For example, a group with three people sharing one label still contributes one event occurrence, because the event is simply “at least two share a birthday.” When the trials are complete, divide the number of groups with a match by the total number of groups.

$$ \text{Estimated probability} = \frac{\text{number of simulated groups with a match}} {\text{number of simulated groups}} $$

This relative frequency is an estimate based on the trials you ran. As discussed in The Law of Large Numbers in Simulations, results from more repeated trials generally settle closer to the probability in the model, although any particular run can vary.

Worked Example: Estimate the Chance of a Match in Four-Person Groups

A student wants to estimate the chance that at least two people share a birthday in a group of four, when birthdays are modeled as equally likely to be one of six dates. The student runs randInt(1,6,4) repeatedly. The following lists are illustrative calculator output from 12 simulated trials.

State: Estimate the probability that at least two of four people share a birthday when each birthday is modeled as an independent, equally likely choice from six dates.
Plan: Use randInt(1,6,4) once per trial. This produces four labels from the inclusive range 1–6. Check each list for any repeated label and record one “yes” if a repeat occurs, otherwise “no.” The model conditions match the question: each person receives one of six equally likely dates, each person’s assignment is independent, and repeats are allowed because birthdays can coincide.

Do: Classify each list and count the “yes” results.

TrialGenerated birthdaysMatch?
11, 4, 2, 6No
23, 3, 5, 1Yes
36, 2, 4, 1No
45, 2, 5, 3Yes
54, 1, 6, 2No
62, 6, 2, 4Yes
71, 3, 5, 6No
84, 4, 2, 5Yes
96, 1, 3, 2No
105, 1, 1, 4Yes
112, 3, 6, 5No
123, 6, 4, 3Yes

There are six “yes” results among the 12 trials. Substituting these counts into the relative-frequency formula gives:

$$ \text{Estimated probability} = \frac{6}{12} = 0.50 $$
Conclude: In these 12 simulated groups, the event occurred in 0.50, or 50%, of the trials. Thus, this run estimates a 50% chance of a birthday match in a four-person group under the six-date model. Because the estimate is based on only 12 trials, another run may give a different relative frequency.

Use randInt(0,9) with a Rejection Rule

You can also build birthday labels from single random digits. The TI-84 command randInt(0,9) produces one integer from 0 through 9. However, there are ten possible digits and only six birthday labels. Assigning some digits to one birthday and more digits to another would make the dates unequally likely.

Instead, use 0 through 5 and reject 6 through 9. Map each accepted digit to a birthday label by adding 1: 0 represents birthday 1, 1 represents birthday 2, and so on through 5 representing birthday 6. If the command returns 6, 7, 8, or 9, discard that digit and draw again for the same person. Continue until four accepted digits have been mapped to birthdays.

Conditions for the digit method:
  • Use digits 0–5 as the six birthday outcomes, with each digit assigned to a different birthday.
  • Reject digits 6–9 and draw again for the birthday that is still needed.
  • Keep accepted repeated labels; different people may share a birthday.
  • Stop after four accepted labels to finish one group, then begin a fresh group for the next trial.

This rejection rule keeps the six modeled dates equally likely: each date corresponds to exactly one of the six accepted digits. Some draws are discarded, so this method may take more calculator entries than directly using randInt(1,6,4). Do not treat a rejected digit as a person or as a birthday.

Worked Example: Make a Birthday Group from Single Random Digits

For one group of four people, suppose repeated uses of randInt(0,9) produce the sequence 8, 3, 0, 5, 7, 0. Apply the rejection and mapping rules in order.

Process the first digit: Reject 8 because it is in the unused range 6–9. No birthday has been assigned yet.

Continue until four birthdays are assigned: Accept 3 and map it to birthday 4. Accept 0 and map it to birthday 1. Accept 5 and map it to birthday 6. Reject 7 because it is unused. Accept the final 0 and map it to birthday 1.

DigitActionBirthday label, if accepted
8Reject—
3Accept4
0Accept1
5Accept6
7Reject—
0Accept1

The completed group is 4, 1, 6, 1. Birthday 1 appears twice, so this trial has a match. The second accepted 0 is used rather than skipped: it represents another person with birthday 1.

Common Mistakes and AP Exam Tips

  • Confusing people with trials. In randInt(1,6,4), the final 4 generates four birthdays for one group. To simulate more groups, repeat the command and record one result per group.
  • Removing a repeated birthday. The model allows two people to have the same date. Skipping a repeat would change the chance process and could prevent the event you are trying to record.
  • Counting matches instead of groups. A group with several repeated labels is still one trial. Record whether the event happened, then count that trial once.
  • Using all ten digits as if there were six outcomes. For the randInt(0,9) method, digits 6–9 must be rejected. Otherwise the six dates will not have equal chances under the digit assignment.
  • Starting a new trial with a restricted set of labels. Each simulated group represents new people whose birthdays can be any of the six dates. Do not remove a birthday label after it appears in an earlier group.
  • Calling a short-run frequency the exact probability. State how many simulated groups had a match and how many groups were run. Describe the ratio as an estimate from that simulation, not as a guaranteed exact value.

A complete simulation description names the model, the number of people in one trial, the calculator command or digit-mapping rules, the event being recorded, and how the results will be summarized. For this example, a clear report says that four birthdays are generated per trial, any repeated label counts as a match, and the number of matching groups is divided by the total number of groups.

Key takeaway: Use randInt(1,6,n) to generate \(n\) birthday labels for one group, then repeat the command to simulate more groups. Keep repeated birthdays because a match is the event of interest. If using randInt(0,9), reject digits 6–9 and map 0–5 to the six dates. Estimate the probability with the relative frequency of groups that contain a match.

Check Your Understanding

Use the six-date, four-person birthday model unless a question states otherwise.

  1. What does the final argument 4 represent in randInt(1,6,4)?
  2. A generated group is 2, 6, 2, 4. Does the event occur? What should be recorded for that trial?
  3. When using randInt(0,9), what should you do if the digit is 7? Should that digit count as one of the four birthdays?
  4. In 30 simulated groups, 18 contain a match. What is the estimated probability from those trials?
  5. Why is it appropriate to keep the same birthday label if it appears for a second person in a group?