Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SIRC ParamEst Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rivnyák Tímea
SIRC ParamEst Project
Commits
849018c0
Commit
849018c0
authored
4 years ago
by
Onica Klaudia
Browse files
Options
Downloads
Patches
Plain Diff
Least square estimation algorithm
parent
761ac7bc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SIRC.asv
+64
-0
64 additions, 0 deletions
SIRC.asv
SIRC.m
+34
-18
34 additions, 18 deletions
SIRC.m
lsq.m
+4
-0
4 additions, 0 deletions
lsq.m
with
102 additions
and
18 deletions
SIRC.asv
0 → 100644
+
64
−
0
View file @
849018c0
%% System initalization
% Population
N = 1000;
% Initial number of infected individuals
I0 = 10;
% Initial number of recovered individuals
R0 = 0;
% Initial number of carrier individuals
C0 = 0;
% Everyone else is susceptible
S0 = N - I0 - R0 - C0;
% Initial parameteres
nu = 14;
mu = 0.015;
epsilon = 1.2;
beta = 0.0002;
gamma = 0.05;
Gamma = 0.03;
q = 0.8;
time = 200;
%t = linspace(0, time, time);
y0 = [S0, I0, R0, C0];
[t, y] = ode45(@(t, y) deriv(y, nu, mu, epsilon, beta, gamma, Gamma, q), [0 time], y0);
% figure(1)
% plot(t, y);
% xlabel('Time(days)');
% ylabel('Number of individuals');
% legend('S', 'I', 'R', 'C');
%% Add noise
% noise = wgn(size(t,1), 4, 0, 42);
% y_noise = y + noise;
%
% figure(2)
% plot(t, y_noise);
% xlabel('Time(days)');
% ylabel('Number of individuals');
% legend('S', 'I', 'R', 'C');
[t_noisy, y_noisy] = ode45(@(t, y) noisy_deriv(y, nu, mu, epsilon, beta, gamma, Gamma, q), [0 time], y0);
% figure(3)
% plot(t_noisy, y_noisy);
% xlabel('Time(days)');
% ylabel('Number of individuals');
% legend('S', 'I', 'R', 'C');
%% Least square estimation
% The matrices of known properties
% X_S = [ones(size(y_noisy, 1)-1, 1), y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 1)];
% X_I = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 1)];
% X_R = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 3)];
% X_C = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4)];
%
% theta_s = lsq(X_S, y_noisy(2:end,1));
% dSdt + dIdt = nu - mu*S - (gamma+mu)*I
X_SI = [ones(size(y_noisy, 1)-1, 1),
\ No newline at end of file
This diff is collapsed.
Click to expand it.
SIRC.m
+
34
−
18
View file @
849018c0
...
...
@@ -24,28 +24,44 @@ time = 200;
y0
=
[
S0
,
I0
,
R0
,
C0
];
[
t
,
y
]
=
ode45
(
@
(
t
,
y
)
deriv
(
y
,
nu
,
mu
,
epsilon
,
beta
,
gamma
,
Gamma
,
q
),
[
0
time
],
y0
);
figure
(
1
)
plot
(
t
,
y
);
xlabel
(
'Time(days)'
);
ylabel
(
'Number of individuals'
);
legend
(
'S'
,
'I'
,
'R'
,
'C'
);
%
figure(1)
%
plot(t, y);
%
xlabel('Time(days)');
%
ylabel('Number of individuals');
%
legend('S', 'I', 'R', 'C');
%% Add noise
noise
=
wgn
(
size
(
t
,
1
),
4
,
0
,
42
);
y_noise
=
y
+
noise
;
figure
(
2
)
plot
(
t
,
y_noise
);
xlabel
(
'Time(days)'
);
ylabel
(
'Number of individuals'
);
legend
(
'S'
,
'I'
,
'R'
,
'C'
);
%
noise = wgn(size(t,1), 4, 0, 42);
%
y_noise = y + noise;
%
%
figure(2)
%
plot(t, y_noise);
%
xlabel('Time(days)');
%
ylabel('Number of individuals');
%
legend('S', 'I', 'R', 'C');
[
t_noisy
,
y_noisy
]
=
ode45
(
@
(
t
,
y
)
noisy_deriv
(
y
,
nu
,
mu
,
epsilon
,
beta
,
gamma
,
Gamma
,
q
),
[
0
time
],
y0
);
figure
(
3
)
plot
(
t_noisy
,
y_noisy
);
xlabel
(
'Time(days)'
);
ylabel
(
'Number of individuals'
);
legend
(
'S'
,
'I'
,
'R'
,
'C'
);
% figure(3)
% plot(t_noisy, y_noisy);
% xlabel('Time(days)');
% ylabel('Number of individuals');
% legend('S', 'I', 'R', 'C');
%% Least square estimation
% The matrices of known properties
% X_S = [ones(size(y_noisy, 1)-1, 1), y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 1)];
% X_I = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 1)];
% X_R = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4), y_noisy(1:end-1, 3)];
% X_C = [y_noisy(1:end-1, 2), y_noisy(1:end-1, 4)];
% dSdt + dIdt = nu - mu*S - (gamma+mu)*I
X_SI
=
[
ones
(
size
(
y_noisy
,
1
)
-
1
,
1
),
y_noisy
(
1
:
end
-
1
,
1
),
y_noisy
(
1
:
end
-
1
,
2
)];
Y_SI
=
y_noisy
(
2
:
end
,
1
)
-
y_noisy
(
1
:
end
-
1
,
1
)
+
y_noisy
(
2
:
end
,
2
)
-
y_noisy
(
1
:
end
-
1
,
2
);
Y_SI2
=
y_noisy
(
2
:
end
,
1
)
+
y_noisy
(
2
:
end
,
2
);
theta_SI
=
lsq
(
X_SI
,
Y_SI
);
theta_SI2
=
lsq
(
X_SI
,
Y_SI2
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lsq.m
0 → 100644
+
4
−
0
View file @
849018c0
function params = lsq(X, Y)
params = (X'*X)\(X'*Y);
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment