Course contents 02 / 22

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.

Prerequisites

What probability is

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 Ω\Omega 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 (a,c,a)(a,c,a), and

Ω={a,b,c,d,e}3,∣Ω∣=53=125.\Omega=\{a,b,c,d,e\}^3,\qquad |\Omega|=5^3=125.

An event is a set of outcomes. In this finite model all subsets are admitted as events. Let AA mean that the first position contains a, and BB 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 AA, 25 in BB, and 5 in A∩BA\cap B: the middle position is free. Therefore A∪BA\cup B, meaning at least one of these two events, contains 25+25−5=4525+25-5=45 tuples. Subtracting the overlap prevents counting (a,c,a)(a,c,a) twice.

Set notation supplies the logic. A∩BA\cap B means both events; A∪BA\cup B means either or both; Ac=Ω∖AA^c=\Omega\setminus A means that AA does not occur. Events are disjoint when A∩B=∅A\cap B=\varnothing. De Morgan’s identity (A∪B)c=Ac∩Bc(A\cup B)^c=A^c\cap B^c 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 1/1251/125. Consequently

P(A∩B)=5125=125,P(A∪B)=45125=925.P(A\cap B)=\frac5{125}=\frac1{25},\qquad P(A\cup B)=\frac{45}{125}=\frac9{25}.

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 (a,b,a)(a,b,a), (a,a,b)(a,a,b) and (b,a,a)(b,a,a) all become the allocation (a,a,b)(a,a,b). The allocation (a,a,a)(a,a,a) has only one ordered predecessor; (a,b,c)(a,b,c) has six. Thus their probabilities under uniform ordered schedules are 3/1253/125, 1/1251/125 and 6/1256/125, respectively.

This is a general mechanism. A recording function ff maps detailed outcomes to summaries. For a summary yy, its fibre f−1(y)f^{-1}(y) is the set of detailed outcomes that produce it. If the detailed outcomes are uniformly distributed, then

P(f(ω)=y)=∣f−1(y)∣∣Ω∣.P(f(\omega)=y)=\frac{|f^{-1}(y)|}{|\Omega|}.

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 kk stages, and stage jj always has njn_j possible continuations, the total is

∏j=1knj.\prod_{j=1}^k n_j.

The available choices may depend on previous decisions; their number must remain njn_j 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 5⋅4⋅3=605\cdot4\cdot3=60. 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 2+1+3=62+1+3=6, not 3⋅3=93\cdot3=9. 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 kk out of nn#

For nn distinct labels and a selection of size kk, two decisions determine the counting space: whether positions are retained and whether a label may repeat. Assume n≥1n\ge1, k≥0k\ge0; the no-repetition formulas below require k≤nk\le n. The empty selection has one form, and 0!=10!=1.

Recorded objectMay a label repeat?NumberFive labels, three positions
Ordered tupleYesnkn^k125
Ordered tupleNon!/(n−k)!n!/(n-k)!60
Set of labelsNo(nk)\binom nk10
Multiset of labels, retaining multiplicitiesYes(n+k−1k)\binom{n+k-1}{k}35

A set and a multiset are different records: a set cannot distinguish (a,a,b)(a,a,b) from (a,b,b)(a,b,b), whereas a multiset retains those multiplicities. Without repetition there are k!k! orders for every selected set. Dividing the ordered count by that common factor gives (nk)=n!/[k!(n−k)!]\binom nk=n!/[k!(n-k)!].

With repetition, division by k!k! is wrong because different multisets have different numbers of orders. Instead write counts c1,…,cn≥0c_1,\ldots,c_n\ge0 with ∑ici=k\sum_i c_i=k. Encode them as kk identical marks separated into nn groups by n−1n-1 separators. Choosing the mark positions among n+k−1n+k-1 positions is a bijection, so the number of such count vectors is (n+k−1k)\binom{n+k-1}{k}. Empty groups are allowed. For example, **||*|| encodes two jobs of type a, none of b, one of c, none of d or e.

Figure

35 allocations have 125 ordered predecessors

Ordered, repeats125
Ordered, no repeats60
Subsets10
Multisets35
aaaDistinct types: 1

5 allocations × 1 order = 5 schedules

aabDistinct types: 2

20 allocations × 3 orders = 60 schedules

abcDistinct types: 3

10 allocations × 6 orders = 60 schedules

Under uniform schedule sampling, one allocation has the weight of its 1, 3 or 6 orders out of 125. The number of records and their probabilities are different quantities.

For any particular count vector, its number of ordered predecessors is

k!∏i=1nci!.\frac{k!}{\prod_{i=1}^n c_i!}.

One way to see the denominator is to label all kk job occurrences temporarily. Their k!k! orders overcount the visible tuple by the permutations within every group of identical labels. For three jobs the possible multiplicity patterns are (3)(3), (2,1)(2,1) and (1,1,1)(1,1,1), 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

P(at least one a)=1−4353=61125.P(\text{at least one a})=1-\frac{4^3}{5^3}=\frac{61}{125}.

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 5⋅4⋅3=605\cdot4\cdot3=60 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 43=644^3=64 schedules, or appears once, giving 3⋅42=483\cdot4^2=48. Thus

Pordered(at most one a)=64+48125=112125.P_{\rm ordered}(\text{at most one a})=\frac{64+48}{125}=\frac{112}{125}.

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:

Pallocation(at most one a)=35−535=67.P_{\rm allocation}(\text{at most one a})=\frac{35-5}{35}=\frac67.

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#

QuestionCalculation 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.