Skip to content

Instantly share code, notes, and snippets.

@HosikChae
Created February 27, 2020 02:09
Show Gist options
  • Save HosikChae/ff7eabdcf85ae4c08ad72aff153f3ec7 to your computer and use it in GitHub Desktop.
Save HosikChae/ff7eabdcf85ae4c08ad72aff153f3ec7 to your computer and use it in GitHub Desktop.
Fitting the number of Corona patients in Korea
clear; clc; close all;
% from 'cdc.go.kr'
data_Feb = [12, 15, 15, 16, 18, 23, 24, 22, 23, 27, 28, 28, 28, 28, 28, 29, 30, 31, 46, 82, 156, 346, 556, 763, 893, 1146, 1595];
max_capacity = 7500;
t = 1:length(data_Feb);
x0 = [1 1];
F = @(x,xdata)x(1)*exp(-x(2)*xdata);% + x(3)*exp(-x(4)*xdata);
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,t,data2);
dF = @(x, xdata) -x(1)*x(2)*exp(-x(2)*xdata);
tt = 1:35;
[a, ttm] = min(abs(dF(x, tt)-max_capacity));
% The figures from CDC
plot(t, data2, 'b-*'); hold on;
% Estimatied numbers, clipping increments below the investication capacity
F1 = F(x, tt(1:ttm));
F2 = F1(end) + max_capacity*(tt(ttm:end)-ttm);
figure()
plot(t, data2, 'b-*'); hold on;
plot(tt, F1, 'r-');
plot(tt, F2, 'r-');
title('2020년 2월 확진자 수');
xlim([1, length(tt)]); xlabel('날짜 (2월 1일 ~)'); ylabel('확진자 수 [명]');
legend('질본 발표', 'Estimated');
% subplot(211);
% plot(t, data2, 'b-*'); hold on;
% plot(tt, F1, 'r-');
% plot(tt, F2, 'r-');
%
% title('2020년 2월 확진자 수');
% xlim([1, length(tt)]); xlabel('날짜 (2월 1일 ~)'); ylabel('확진자 수 [명]');
% legend('질본 발표', 'Estimated');
%
% subplot(212);
% plot(t, data2, 'b-*'); hold on;
% plot(tt, F1, 'r-');
% plot(tt, F2, 'r-');
%
% title('2020년 2월 확진자 수');
% xlim([1, length(tt)]); ylim([0, 1500]); xlabel('날짜 (2월 1일 ~)'); ylabel('확진자 수 [명]');
% legend('질본 발표', 'Estimated');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment