02 / 22 · Foundations
Outcomes, events and counting
Count the experiment you actually run: events as sets, fixed and variable branching, ordered choices and allocations, and why forgetting order can turn equally likely sequences into unequal probabilities. Exact finite job schedules make every count reproducible.
On this page 6
A scheduler has three positions to fill and five available job types, labelled a through e. It can record the ordered schedule, the set of types used, or the number of jobs of each type. These records describe different objects. A uniform choice of schedules need not give a uniform choice of records after information is discarded.
The introductory note separated a probability model from the mechanism it describes. Here we build finite models carefully enough to calculate with them. The scheduler inputs, compatibility rule, figures and enumeration below were specified for this note with AI assistance. They are fictional mathematical cases, not a benchmark, production trace or adaptation of an external assignment. The standard counting definitions are credited in References.
Outcomes and events#
An outcome is the full result recorded by a model. Its sample space is the set of possible outcomes. In the first scheduler model, each of the three positions independently receives one of the five labels with equal probability. Repetition is allowed. The outcome is a tuple such as , and
An event is a set of outcomes. In this finite model all subsets are admitted as events. Let mean that the first position contains a, and that the last position contains a. The event occurs exactly when the recorded tuple belongs to its set.
The same tuple may belong to both events. There are 25 tuples in , 25 in , and 5 in : the middle position is free. Therefore , meaning at least one of these two events, contains tuples. Subtracting the overlap prevents counting twice.
Set notation supplies the logic. means both events; means either or both; means that does not occur. Events are disjoint when . De Morgan’s identity turns a failure of “either” into “neither.” These are statements about sets before any probabilities are assigned.
Under the stated independent uniform generator, every tuple has probability . Consequently
The denominator is justified by the generator, not by how tidy the list looks. If a job type is preferred or a later position depends on earlier choices, the same 125 tuples can have unequal weights.
Choosing outcomes that are equally likely#
Suppose the display now sorts the schedule before storing it. Tuples , and all become the allocation . The allocation has only one ordered predecessor; has six. Thus their probabilities under uniform ordered schedules are , and , respectively.
This is a general mechanism. A recording function maps detailed outcomes to summaries. For a summary , its fibre is the set of detailed outcomes that produce it. If the detailed outcomes are uniformly distributed, then
The summaries are equally likely exactly when all nonempty fibres have the same size. Counting distinct summaries alone does not establish that condition. Sorting a schedule is a valid change of representation, but its probabilities must be carried along.
A different algorithm could enumerate all allocations and choose one uniformly. That would make the allocations equally likely by construction. It is a different random experiment, even though its output has the same format. We will compare the two algorithms on a capacity constraint below.
The multiplication rule#
To count a set, describe a procedure that generates each object once. If it has stages, and stage always has possible continuations, the total is
The available choices may depend on previous decisions; their number must remain at that stage. With three different job types in the schedule, there are 5 choices first, then 4 unused labels, then 3. The count is . Which labels remain depends on the prefix, but their number does not.
A constraint can break this constant-branching structure. Suppose three processing modes have the following allowed formats: A permits u and v; B permits only v; C permits u, v and w. The valid pairs are (A,u), (A,v), (B,v), (C,u), (C,v), (C,w). Their count is , not . The alternatives for the first stage are disjoint branches, so we add their completion counts.
Counting these six pairs still says nothing about their probabilities. Choosing a mode uniformly and then a permitted format uniformly gives a different distribution from choosing one of the six valid pairs uniformly. The axioms note develops such weighted finite models.
Four ways to choose out of #
For distinct labels and a selection of size , two decisions determine the counting space: whether positions are retained and whether a label may repeat. Assume , ; the no-repetition formulas below require . The empty selection has one form, and .
| Recorded object | May a label repeat? | Number | Five labels, three positions |
|---|---|---|---|
| Ordered tuple | Yes | 125 | |
| Ordered tuple | No | 60 | |
| Set of labels | No | 10 | |
| Multiset of labels, retaining multiplicities | Yes | 35 |
A set and a multiset are different records: a set cannot distinguish from , whereas a multiset retains those multiplicities. Without repetition there are orders for every selected set. Dividing the ordered count by that common factor gives .
With repetition, division by is wrong because different multisets have different numbers of orders. Instead write counts with . Encode them as identical marks separated into groups by separators. Choosing the mark positions among positions is a bijection, so the number of such count vectors is . Empty groups are allowed. For example, **||*|| encodes two jobs of type a, none of b, one of c, none of d or e.
35 allocations have 125 ordered predecessors
aaaDistinct types: 15 allocations × 1 order = 5 schedules
aabDistinct types: 220 allocations × 3 orders = 60 schedules
abcDistinct types: 310 allocations × 6 orders = 60 schedules
For any particular count vector, its number of ordered predecessors is
One way to see the denominator is to label all job occurrences temporarily. Their orders overcount the visible tuple by the permutations within every group of identical labels. For three jobs the possible multiplicity patterns are , and , giving 1, 3 and 6 predecessors. The figure groups all 35 allocations by these patterns; their weights sum to the original 125 schedules.
If repetition is forbidden and the ordered choices are uniform, every three-element set has six predecessors and is uniform among ten sets. If repetition is allowed, the 35 allocations are not uniform under the original ordered generator. Both the counting formula and the sampling mechanism matter.
Worked examples#
First ask whether a appears anywhere. A complement is shorter to count: schedules that avoid a have four choices in every position. Therefore
Next ask for exactly two distinct types. Choose the repeated label in 5 ways, the other label in 4 ways and its position in 3 ways. This yields ordered schedules. Each resulting allocation has three orders, so there are 20 allocations of this shape. This explains the middle row of the figure without relying on its enumeration.
Finally, impose a resource limit: type a may appear at most once. Under the uniform ordered generator, either a is absent, giving schedules, or appears once, giving . Thus
Now use the alternative algorithm that samples uniformly from the 35 allocations. Excluded allocations contain either two a’s and one of four other labels, or three a’s. Five allocations are excluded, leaving 30:
These answers differ because the algorithms distribute probability differently. Neither is a rounding error. An exact program should reproduce both after its sampling rule is specified; merely checking that it returns 35 unique allocations cannot decide which distribution it generates.
What changed#
| Question | Calculation justified here |
|---|---|
| How many detailed schedules? | Multiply the fixed branch counts. |
| How many schedules obey a rule? | Count disjoint cases, or count a complement. |
| What does forgetting order do? | Group tuples into fibres and keep their sizes. |
| Are the summaries uniform? | Check equal fibre sizes or specify a different uniform generator. |
Limitations#
This note works with finite spaces. Its ratio of counts requires uniform weights on the space used in that ratio. Independence and uniformity of the three position choices are explicit assumptions of the fictional generator; counting alone proves neither. Enumeration confirms the finite construction, not that a real scheduler follows it. Continuous outcomes need a different measure, and even finite outcomes with unequal probabilities require weighted sums. The four formulas also do not solve every constrained counting problem: variable branch sizes, capacities and indistinguishable records must be handled explicitly.
What you should remember#
An outcome records the experiment at a chosen level of detail; an event selects outcomes. Count each detailed object once, justify the denominator’s probabilities, and account for information lost by a summary. The crucial distinction in the scheduler is between 35 possible allocations and the unequal weights that the 125 uniform schedules give them.
Code#
This standard-library example exhaustively checks all 125 schedules. It uses no random samples or external data. The fuller companion verifier also checks the four counting spaces, event intersections and variable branching.
from collections import Counter
from fractions import Fraction
from itertools import product
schedules = list(product('abcde', repeat=3))
allocations = Counter(tuple(sorted(s)) for s in schedules)
print('schedules, allocations:', len(schedules), len(allocations))
for kinds in (1, 2, 3):
groups = [a for a in allocations if len(set(a)) == kinds]
weights = {allocations[a] for a in groups}
print('distinct labels, allocations, weights:', kinds, len(groups), sorted(weights))
ordered_ok = sum(s.count('a') <= 1 for s in schedules)
allocation_ok = sum(a.count('a') <= 1 for a in allocations)
print('at most one a:', Fraction(ordered_ok, len(schedules)),
Fraction(allocation_ok, len(allocations)))
schedules, allocations: 125 35
distinct labels, allocations, weights: 1 5 [1]
distinct labels, allocations, weights: 2 20 [3]
distinct labels, allocations, weights: 3 10 [6]
at most one a: 112/125 6/7
Next#
Once weights are unequal, counting needs a probability attached to each detailed outcome. Kolmogorov’s axioms state how those weights combine and extend the model beyond finite sets. Sampling a fixed number of distinct objects later leads to the hypergeometric distribution in Discrete distributions.
References#
Kyle Siegrist’s Random provides the reference definitions: Events and Random Variables, sections “Events” and “The Language of Events”; Counting Measure, the addition and multiplication rules; Combinatorial Structures, permutations, combinations and sampling; and Probability Measure, discrete uniform distributions. The author identifies that work as CC BY 2.0. These are credited mathematical references; their exercise texts, figures and software are not reproduced here. The finite scheduler case, prose, diagram and code are newly composed for this project.