diff options
Diffstat (limited to 'fits.cpp')
-rw-r--r-- | fits.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -22,14 +22,8 @@ inline Real basisFunctions(unsigned N, unsigned i, Real x) { } */ -Real legendreP(unsigned n, Real x) { - if (n == 0) return 1; - else if (n == 1) return x; - else return ((2 * (n - 1) + 1) * x * legendreP(n - 1, x) - (n - 1) * legendreP(n - 2, x)) / n; -} - inline Real basisFunctions(unsigned N, unsigned i, Real x) { - return legendreP(i, x); + return std::legendre(i, 0.5 * (x + 1.0)); } /* @@ -91,7 +85,7 @@ Vector gradientDescent(const std::list<std::tuple<Real, Real>>& data, const Vect while ( xₜ₊₁ = xₜ - α * ∇H, Hₜ₊₁ = cost(data, xₜ₊₁), - Hₜ₊₁ > Hₜ - 0.5 * α * m + Hₜ₊₁ > Hₜ - 0.0 * α * m ) { α /= 2; } |