Linear regression #
over ℝ or ℂ
noncomputable def
K₁
{n : ℕ}
{R : Type u_1}
[RCLike R]
(x : Fin n → R)
:
Submodule R (EuclideanSpace R (Fin n))
Equations
- K₁ x = Submodule.span R {WithLp.toLp 2 x, WithLp.toLp 2 fun (x : Fin n) => 1}
Instances For
noncomputable def
regression_coordinates₁
{n : ℕ}
{R : Type u_1}
[RCLike R]
(x y : Fin n → R)
(lin_indep : LinearIndependent R (Kvec₁ x))
:
Fin 2 → R
Given points (x i, y i), obtain the coordinates [c, d] such that
y = c x + d is the best fit regression line.
Equations
- regression_coordinates₁ x y lin_indep i = ((Module.Basis.mk lin_indep ⋯).repr ⟨(K₁ x).starProjection (WithLp.toLp 2 y), ⋯⟩) i
Instances For
theorem
indep_of_nonconstant
{m : ℕ}
{x : Fin m → ℝ}
(h : nonconstant x)
:
LinearIndependent ℝ (Kvec₁ x)
Multivariate regression.
Equations
- K₂ x₀ x₁ = Submodule.span ℝ {WithLp.toLp 2 x₀, WithLp.toLp 2 x₁, WithLp.toLp 2 fun (x : Fin n) => 1}
Instances For
noncomputable def
regression_coordinates₂
{n : ℕ}
(x₀ x₁ y : Fin n → ℝ)
(lin_indep : LinearIndependent ℝ (Kvec₂ x₀ x₁))
:
Equations
- regression_coordinates₂ x₀ x₁ y lin_indep i = ((Module.Basis.mk lin_indep ⋯).repr ⟨(K₂ x₀ x₁).starProjection (WithLp.toLp 2 y), ⋯⟩) i