You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fit(::Type{<:AbstractPolynomial}, x, y, deg=length(x)-1; [weights], var=:x)
65
-
66
-
Fit the given data as a polynomial type with the given degree. Uses linear least squares. When weights are given, as either a `Number`, `Vector` or `Matrix`, will use weighted linear least squares. The default polynomial type is [`Polynomial`](@ref). This will automatically scale your data to the [`domain`](@ref) of the polynomial type using [`mapdomain`](@ref). To specify a different range to scale to, specify `domain=(a,b)` where `a <= minimum(xs) && maximum(xs) <= b`.
Fit the given data as a polynomial type with the given degree. Uses linear least squares. When weights are given, as either a `Number`, `Vector` or `Matrix`, will use weighted linear least squares. The default polynomial type is [`Polynomial`](@ref). This will automatically scale your data to the [`domain`](@ref) of the polynomial type using [`mapdomain`](@ref)
67
66
"""
68
67
functionfit(P::Type{<:AbstractPolynomial},
69
68
x::AbstractVector{T},
70
69
y::AbstractVector{T},
71
-
deg::Integer=length(x) -1;
72
-
domain=(minimum(x), maximum(x)),
73
-
weights =nothing,
74
-
var =:x,) where {T}
75
-
x =mapdomain(P, first(domain),last(domain)).(x)
70
+
deg::Integer=length(x) -1;
71
+
weights =nothing,
72
+
var =:x,) where {T}
73
+
x =mapdomain(P, x)
76
74
vand =vander(P, x, deg)
77
75
if weights !==nothing
78
76
coeffs =_wlstsq(vand, y, weights)
79
77
else
80
-
coeffs =vand \ y #pinv(vand) * y
78
+
coeffs =pinv(vand) * y
81
79
end
82
80
returnP(T.(coeffs), var)
83
81
end
@@ -196,7 +194,8 @@ In-place version of [`chop`](@ref)
0 commit comments