TP-traitement-audio-visuel/TP1/moindres_carres.m
2023-06-22 20:47:16 +02:00

15 lines
316 B
Matlab

function estimation = moindres_carres(D_app, beta_0, beta_d, d)
X = D_app(1, :)';
Y = D_app(2, :)';
B = Y - beta_0 * (1 - X).^d - beta_d * (X.^d);
A = zeros(length(X), d - 1);
for i = 1:(d - 1)
A(:, i) = nchoosek(d, i) .* X.^i .* (1 - X).^(d - i);
end
estimation = A \ B;
end