An interval is a set of real numbers between lower and upper bounds, written [a, b] when both endpoints are included. It can contain integers, decimals, fractions, and infinitely many other values. Intervals describe the possible values of continuous random variables, although values within the interval need not be equally likely. section 2.3
Intervals also translate probability into an operational sampling rule. After probabilities are accumulated into a cumulative distribution function, each outcome receives a corresponding portion of a random-number space. A generated number falling inside that interval selects the associated outcome. section 9.2 section 9.3.3
Use intervals to:
- Represent the possible values of a continuous measurement, such as a completion time bounded between 2 and 6 hours. section 2.3
- Assign simulated outcomes to probability-based ranges, giving more probable outcomes larger portions of the random-number space. section 9.3.3
- Measure sample variability through the range, calculated as the maximum value minus the minimum value, for quality-control monitoring. section 14.1.4
Probability intervals in a simulation
Suppose an outcome has cumulative probability 0.40. The interval [0.00, 0.40] maps generated random numbers to that outcome. In a two-digit scheme, an outcome with probability 27% receives approximately 27 digits; an example assignment is 13–39. A number in that range selects the outcome during a trial. section 9.2 section 9.3.3
>>> random_digits = [f'{i:02}' for i in range(0, 100)] #1
>>> random_digits_ranges = [] #2
>>> current_index = 0 #3
>>> total_digits = len(random_digits) #4
>>> for i, row in poisson_table.iterrows(): #5
>>> count = max(1, int(row['Probability (%)'])) #6
>>> end_index = (current_index + count - 1) % total_digits #7
>>> if current_index <= end_index: #8
>>> start = random_digits[current_index] #9
>>> end = random_digits[end_index] #10
>>> random_digits_ranges.append(f’{start}-‘ \
>>> f’{end}’) #11
>>> else: #12
>>> start = random_digits[current_index] #13
>>> end = random_digits[end_index] #14
>>> random_digits_ranges.append(f’{start}-99, ‘ \
>>> f’00-{end}') #15
>>> current_index = \
>>> (end_index + 1) % total_digits #16
>>> poisson_table['Random Digits'] = \
>>>. random_digits_ranges #17
>>> print(poisson_table) #18
k Probability (%) Cumulative Probability (%) Random Digits
0 0 13.53 13.53 00-12
1 1 27.07 40.60 13-39
2 2 27.07 67.67 40-66
3 3 18.04 85.71 67-84
4 4 9.02 94.73 85-93
5 5 3.61 98.34 94-96
6 6 1.20 99.55 97-97
7 7 0.34 99.89 98-98
8 8 0.09 99.98 99-99
Inspect the Python listing that creates sequential two-digit ranges, handles wraparound at 99, and associates ranges with probability-table outcomes. section 9.3.3






