agamvik

SIMULASI COVID DIAMOND PRINCESS

Mar 20th, 2020
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. clc
  2. clear all
  3. S(1) = 3699;
  4. I(1) = 1;
  5. R(1) = 0;
  6. N = 3700;
  7.  
  8. ttes = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  9. ];
  10. Ites = [0 0 0 0 0 0 61 61 64 135 135 175 175 218 285 355 454 542 621 634 634 634 691 691 691 705 705 705 705 705 705 706 706 706 696
  11. ];
  12.  
  13. t(1) = 0;
  14. dt = 1;
  15. T = 50;
  16.  
  17. for j=1:10000;
  18. betha(j) = 0.6 + 0.2*rand(1);
  19. gamma(j) = 0.2 + 0.1*rand(1);
  20. %------------SIR-------------
  21. for i=1:T;
  22. S(i+1) = S(i) - (betha(j)*S(i)*I(i)/N)*dt;
  23. I(i+1) = I(i) + (betha(j)*S(i)*I(i)/N - gamma(j)*I(i))*dt;
  24. R(i+1) = R(i) + gamma(j)*I(i)*dt;
  25. t(i+1) = t(i) + dt;
  26. end
  27.  
  28. Y = I(1:length(Ites));
  29. e = (Ites-Y).^2;
  30. LS(j) = sum(e);
  31. end
  32. min(LS) % 1.0846e+06
  33. x = find(LS == min(LS));
  34. b = betha(x)
  35. g = gamma(x)
  36.  
  37. %% ==== PLOT ====
  38. b = 0.6287;
  39. g = 0.2532;
  40. for i=1:T;
  41. S(i+1) = S(i) - (b*S(i)*I(i)/N)*dt;
  42. I(i+1) = I(i) + (b*S(i)*I(i)/N - g*I(i))*dt;
  43. R(i+1) = R(i) + g*I(i)*dt;
  44. t(i+1) = t(i) + dt;
  45. end
  46. plot(t,S,t,I,t,R)
  47. hold on
  48. plot(ttes, Ites,'ok');
  49. title('SIR Model')
  50. legend('S','I','R','I real')
  51. xlabel('Time (days)')
  52. ylabel('Number of people')
Advertisement
Add Comment
Please, Sign In to add comment