15 lines
316 B
Mathematica
15 lines
316 B
Mathematica
|
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
|