Gaussian maximum likelihood
TheoremLog-density of the multivariate Gaussian#✓fully proved
Let \(J\) be a finite set with \(n\) elements, let \(\mu, x \in \mathbb{R}^J\), let \(S\) be a positive definite real \(J \times J\) matrix, and write \(\mathcal{N}(x \mid \mu, S)\) for the multivariate Gaussian density at \(x\) with mean \(\mu\) and covariance \(S\). Then \(\log \mathcal{N}(x \mid \mu, S) = -\frac{n}{2} \log (2\pi) - \frac{1}{2} \log \det S - \frac{1}{2} (x - \mu)^{\mathsf T} S^{-1} (x - \mu)\).
theorem log_multivariateGaussianPDFReal (μ : EuclideanSpace ℝ n) {S : Matrix n n ℝ}
(hS : S.PosDef) (x : EuclideanSpace ℝ n) :
log (multivariateGaussianPDFReal μ S x) = -(Fintype.card n / 2) * log (2 * π) -
log S.det / 2 - ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ) / 2
noncomputable def multivariateGaussianPDFReal (μ : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ)
(x : EuclideanSpace ℝ ι) : ℝ :=
((√(2 * Real.pi)) ^ Fintype.card ι)⁻¹ * (√S.det)⁻¹ *
Real.exp (-(ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ)) / 2)
MathlibExt/Probability/Distributions/GaussianDensity.lean:183
Uses 1 · Used by 1
TheoremThe weighted Gaussian log-likelihood via the scatter matrix#✓fully proved
Let \(I\) be a finite set and \(J\) a finite set with \(n\) elements, let \(x_i \in \mathbb{R}^J\) (\(i \in I\)) be points with real weights \(w_i\) whose sum \(W = \sum_{i \in I} w_i\) is nonzero, let \(\mu \in \mathbb{R}^J\), let \(S\) be a positive definite real \(J \times J\) matrix, and let \(C(\mu)\) be the weighted scatter matrix of the \(x_i\) about \(\mu\). Write \(\mathcal{N}(x \mid \mu, S)\) for the multivariate Gaussian density at \(x\) with mean \(\mu\) and covariance \(S\). Then \(\sum_{i \in I} w_i \log \mathcal{N}(x_i \mid \mu, S) = -\frac{W}{2} \big(n \log (2\pi) + \log \det S + \operatorname{tr}(S^{-1} C(\mu))\big)\).
theorem sum_mul_log_multivariateGaussianPDFReal_eq {w : ι → ℝ} (hw : ∑ i, w i ≠ 0)
(xs : ι → EuclideanSpace ℝ n) (μ : EuclideanSpace ℝ n) {S : Matrix n n ℝ} (hS : S.PosDef) :
∑ i, w i * log (multivariateGaussianPDFReal μ S (xs i)) =
-((∑ i, w i) / 2) * (Fintype.card n * log (2 * π) + log S.det +
(S⁻¹ * weightedScatter w xs μ).trace)
noncomputable def multivariateGaussianPDFReal (μ : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ)
(x : EuclideanSpace ℝ ι) : ℝ :=
((√(2 * Real.pi)) ^ Fintype.card ι)⁻¹ * (√S.det)⁻¹ *
Real.exp (-(ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ)) / 2)
MathlibExt/Probability/Distributions/GaussianDensity.lean:183
noncomputable def weightedScatter (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n)
(μ : EuclideanSpace ℝ n) : Matrix n n ℝ :=
(∑ i, w i)⁻¹ • ∑ i, w i • vecMulVec (ofLp (xs i - μ)) (ofLp (xs i - μ))
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:53
Uses 4 · Used by 3
TheoremThe weighted mean is the Gaussian MLE of the mean#✓fully proved
Let \(I\) and \(J\) be finite sets, let \(x_i \in \mathbb{R}^J\) (\(i \in I\)) be points with real weights \(w_i\) such that \(\sum_i w_i > 0\), let \(m\) be their weighted mean, and let \(S\) be a positive definite real \(J \times J\) matrix. Write \(\mathcal{N}(x \mid \mu, S)\) for the multivariate Gaussian density at \(x\) with mean \(\mu\) and covariance \(S\). Then for every \(\mu \in \mathbb{R}^J\), \(\sum_{i \in I} w_i \log \mathcal{N}(x_i \mid \mu, S) \le \sum_{i \in I} w_i \log \mathcal{N}(x_i \mid m, S)\).
theorem sum_mul_log_multivariateGaussianPDFReal_le_weightedMean {w : ι → ℝ}
(hw : 0 < ∑ i, w i) (xs : ι → EuclideanSpace ℝ n) (μ : EuclideanSpace ℝ n)
{S : Matrix n n ℝ} (hS : S.PosDef) :
∑ i, w i * log (multivariateGaussianPDFReal μ S (xs i)) ≤
∑ i, w i * log (multivariateGaussianPDFReal (weightedMean w xs) S (xs i))
noncomputable def multivariateGaussianPDFReal (μ : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ)
(x : EuclideanSpace ℝ ι) : ℝ :=
((√(2 * Real.pi)) ^ Fintype.card ι)⁻¹ * (√S.det)⁻¹ *
Real.exp (-(ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ)) / 2)
MathlibExt/Probability/Distributions/GaussianDensity.lean:183
noncomputable def weightedMean (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n) : EuclideanSpace ℝ n :=
(∑ i, w i)⁻¹ • ∑ i, w i • xs i
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:48
Uses 6 · Used by 1
TheoremThe weighted Gaussian MLE when the sample covariance is positive definite#✓fully proved
Let \(I\) and \(J\) be finite sets, let \(x_i \in \mathbb{R}^J\) (\(i \in I\)) be points with real weights \(w_i\) such that \(\sum_i w_i > 0\), let \(m\) be their weighted mean, and let \(C\) be their weighted scatter matrix about \(m\) (the weighted sample covariance); assume \(C\) is positive definite. Write \(\mathcal{N}(x \mid \mu, S)\) for the multivariate Gaussian density at \(x\) with mean \(\mu\) and covariance \(S\). Then for every \(\mu \in \mathbb{R}^J\) and every positive definite real \(J \times J\) matrix \(S\), \(\sum_{i \in I} w_i \log \mathcal{N}(x_i \mid \mu, S) \le \sum_{i \in I} w_i \log \mathcal{N}(x_i \mid m, C)\).
theorem sum_mul_log_multivariateGaussianPDFReal_le_of_posDef {w : ι → ℝ} (hW : 0 < ∑ i, w i)
{xs : ι → EuclideanSpace ℝ n} (hC : (weightedScatter w xs (weightedMean w xs)).PosDef)
(μ : EuclideanSpace ℝ n) {S : Matrix n n ℝ} (hS : S.PosDef) :
∑ i, w i * log (multivariateGaussianPDFReal μ S (xs i)) ≤
∑ i, w i * log (multivariateGaussianPDFReal (weightedMean w xs)
(weightedScatter w xs (weightedMean w xs)) (xs i))
noncomputable def weightedScatter (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n)
(μ : EuclideanSpace ℝ n) : Matrix n n ℝ :=
(∑ i, w i)⁻¹ • ∑ i, w i • vecMulVec (ofLp (xs i - μ)) (ofLp (xs i - μ))
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:53
noncomputable def weightedMean (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n) : EuclideanSpace ℝ n :=
(∑ i, w i)⁻¹ • ∑ i, w i • xs i
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:48
noncomputable def multivariateGaussianPDFReal (μ : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ)
(x : EuclideanSpace ℝ ι) : ℝ :=
((√(2 * Real.pi)) ^ Fintype.card ι)⁻¹ * (√S.det)⁻¹ *
Real.exp (-(ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ)) / 2)
MathlibExt/Probability/Distributions/GaussianDensity.lean:183
Uses 7 · Used by 2
TheoremThe weighted Gaussian MLE for points in general position#✓fully proved
Let \(I\) be a nonempty finite set and \(J\) a finite set, and let \(x_i \in \mathbb{R}^J\) (\(i \in I\)) be points with positive weights \(w_i > 0\) that do not all lie in an affine hyperplane: for every nonzero \(v \in \mathbb{R}^J\) there are \(i, j \in I\) with \(\langle v, x_i \rangle \ne \langle v, x_j \rangle\). Let \(m\) be their weighted mean and \(C\) their weighted scatter matrix about \(m\) (the weighted sample covariance), and write \(\mathcal{N}(x \mid \mu, S)\) for the multivariate Gaussian density at \(x\) with mean \(\mu\) and covariance \(S\). Then for every \(\mu \in \mathbb{R}^J\) and every positive definite real \(J \times J\) matrix \(S\), \(\sum_{i \in I} w_i \log \mathcal{N}(x_i \mid \mu, S) \le \sum_{i \in I} w_i \log \mathcal{N}(x_i \mid m, C)\).
theorem sum_mul_log_multivariateGaussianPDFReal_le {w : ι → ℝ} (hw : ∀ i, 0 < w i)
{xs : ι → EuclideanSpace ℝ n}
(hspan : ∀ v : EuclideanSpace ℝ n, v ≠ 0 → ∃ i j, ⟪v, xs i⟫ ≠ ⟪v, xs j⟫) [Nonempty ι]
(μ : EuclideanSpace ℝ n) {S : Matrix n n ℝ} (hS : S.PosDef) :
∑ i, w i * log (multivariateGaussianPDFReal μ S (xs i)) ≤
∑ i, w i * log (multivariateGaussianPDFReal (weightedMean w xs)
(weightedScatter w xs (weightedMean w xs)) (xs i))
noncomputable def multivariateGaussianPDFReal (μ : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ)
(x : EuclideanSpace ℝ ι) : ℝ :=
((√(2 * Real.pi)) ^ Fintype.card ι)⁻¹ * (√S.det)⁻¹ *
Real.exp (-(ofLp (x - μ) ⬝ᵥ S⁻¹ *ᵥ ofLp (x - μ)) / 2)
MathlibExt/Probability/Distributions/GaussianDensity.lean:183
noncomputable def weightedMean (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n) : EuclideanSpace ℝ n :=
(∑ i, w i)⁻¹ • ∑ i, w i • xs i
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:48
noncomputable def weightedScatter (w : ι → ℝ) (xs : ι → EuclideanSpace ℝ n)
(μ : EuclideanSpace ℝ n) : Matrix n n ℝ :=
(∑ i, w i)⁻¹ • ∑ i, w i • vecMulVec (ofLp (xs i - μ)) (ofLp (xs i - μ))
MathlibExt/LinearAlgebra/Matrix/WeightedScatter.lean:53
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.