Skip to content
Snippets Groups Projects
Commit 0efcb9d8 authored by Onica Klaudia's avatar Onica Klaudia
Browse files

Gradient descent method

parent e5aadccb
No related branches found
No related tags found
No related merge requests found
......@@ -207,3 +207,7 @@ title('Instrumental variable method for the SIRC modell with additive Gaussian n
xlabel('Time(days)');
ylabel('Number of individuals');
legend('S', 'I', 'R', 'C');
%% Gradient descent method
% For dCdt = gamma*q*I - (Gamma-mu)*C
theta_C = gd(X_C2, Y_C2, [gamma_lsq2*q_lsq2, Gamma_lsq2-mu_lsq2]', 0.01, 5);
gd.m 0 → 100644
function theta = gd(X, y, theta, alpha, num_iters)
m = length(y);
for iter = 1:num_iters
for i=1:size(X,2)
theta(i) = theta(i) - alpha/m * sum((X*theta - y).*X(:,i));
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment