Distributions on finite sets #
We define the type Distribution α
on a Fintype α
. By restricting ourselves to distributoins on finite types,
a lot of notation and casts are greatly simplified. This suffices for (most) finite-dimensional quantum theory.
We define our own (discrete) probability distribution notion here, instead
of using PMF
from Mathlib, because that uses ENNReals everywhere to maintain compatibility
with MeasureTheory.Measure
.
The probabilities internal to a Distribution are NNReals. This lets us more easily
write the statement that they sum to 1, since NNReals can be added. (Probabilities,
on their own, cannot.) But the FunLike instance gives Prob
out, which carry the
information that they are all in the range [0,1].
Instances For
Make a distribution, proving only that the values are nonnegative and that the sum is 1. The fact that the values are at most 1 is derived as a consequence.
Equations
- Distribution.mk' f h₁ hN = ⟨fun (i : α) => ⟨f i, ⋯⟩, hN⟩
Instances For
Equations
- Distribution.instFunLikeProb = { coe := fun (p : Distribution α) (a : α) => ↑p a, coe_injective' := ⋯ }
Instances For
A distribution is a witness that d is nonempty.
Make an constant distribution: supported on a single element. This is also called, variously, a "One-point distribution", a "Degenerate distribution", a "Deterministic distribution", a "Delta function", or a "Point mass distribution".
Instances For
If a distribution has an element with probability 1, the distribution has a constant.
Make an uniform distribution.
Equations
- Distribution.uniform = ⟨fun (x : α) => ⟨1 / ↑Finset.univ.card, ⋯⟩, ⋯⟩
Instances For
Make a distribution on a product of two Fintypes.
Instances For
Given a distribution on α, extend it to a distribution on Sum α β
by giving it no support on β
.
Equations
- d.extend_right = ⟨fun (x : α ⊕ β) => Sum.casesOn x (↑d) (Function.const β 0), ⋯⟩
Instances For
Given a distribution on α, extend it to a distribution on Sum β α
by giving it no support on β
.
Equations
- d.extend_left = ⟨fun (x : β ⊕ α) => Sum.casesOn x (Function.const β 0) ↑d, ⋯⟩
Instances For
Make a convex mixture of two distributions on the same set.
Equations
Given a distribution on type α and an equivalence to type β, get the corresponding distribution on type β.
Instances For
Distributions on α and β are equivalent for equivalent types α ≃ β.
Equations
- Distribution.congr σ = { toFun := fun (d : Distribution α) => d.relabel σ.symm, invFun := fun (d : Distribution β) => d.relabel σ, left_inv := ⋯, right_inv := ⋯ }
Instances For
A T
-valued random variable over α
is a map var : α → T
along
with a probability distribution distr : Distribution α
.
- var : α → T
- distr : Distribution α
Instances For
Distribution.exp_val
is the expectation value of a random variable X
. Under the hood,
it is the "convex combination over a finite family" on the type T
, afforded by the Mixable
instance,
with the probability distribution of X
as weights.
Equations
- Distribution.expect_val X = ↑(Mixable.mkT ⋯)
Instances For
The expectation value of a random variable over α = Fin 2
is the same as Mixable.mix
with probabiliy weight X.distr 0
The expectation value of a random variable with constant probability distribution constant x
is its value at x
The expectation value of a nonnegative real random variable is also nonnegative
Given a T
-valued random variable X
over α
, mapping over T
commutes with the equivalence over α
Equations
- ⋯ = ⋯