Skip to content

Commit

Permalink
new results based on today's Korean dataset update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Yuryatin authored Apr 14, 2020
1 parent b0a7d0b commit b480a44
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Binary file modified covid19deathcurve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions deathcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

import numpy as np
import pandas as pd
import scipy.special as ss
from ctypes import *
from scipy.special import erf
from ctypes import cdll, c_void_p, c_int
import matplotlib.pyplot as plt
from os.path import abspath
from typing import Tuple
Expand All @@ -88,10 +88,10 @@ def internalLogS(x, b0, b1, b2, b3, b4, b5):
return np.log(np.power(10.0, b0) + np.power(10.0, b1) * x + np.power(10.0, b2) * (x ** 2) + np.power(10.0, b3) * (x ** 3) + np.power(10.0, b4) * (x ** 4) + np.power(10.0, b5) * (x ** 5))

def erf(self, x):
return ss.erf(bestFit.internalLogL(x, self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7)) * 0.5 + 0.5
return erf(bestFit.internalLogL(x, self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7)) * 0.5 + 0.5

def erfFC(self, x):
return ss.erf(bestFit.internalLogS(x, self.b0, self.b1, self.b2, self.b3, self.b4, self.b5)) * (0.5 - self.b7) + 0.5 - self.b7 + self.b6
return erf(bestFit.internalLogS(x, self.b0, self.b1, self.b2, self.b3, self.b4, self.b5)) * (0.5 - self.b7) + 0.5 - self.b7 + self.b6

def hyperbTan(self, x):
return np.tanh(bestFit.internalLogL(x, self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7)) * 0.5 + 0.5
Expand Down Expand Up @@ -135,10 +135,10 @@ def xOverAbsFC(self, x):
'Algebraic function derived from x over (1 + abs(x)) with floor and ceiling']

testFuncsReports = [
'\n\n\tPython\n\tscipy.special.erf(math.log({0:e} + {1:e}*x + {2:e}*(x**2) + {3:e}*(x**3) + {4:e}*(x**4) + {5:e}*(x**5) + {6:e}*(x**6) + {7:e}*(x**7) )) * 0.5 + 0.5\n\n\t' +
'\n\n\tPython\n\tfrom scipy.special import erf\n\terf(math.log({0:e} + {1:e}*x + {2:e}*(x**2) + {3:e}*(x**3) + {4:e}*(x**4) + {5:e}*(x**5) + {6:e}*(x**6) + {7:e}*(x**7) )) * 0.5 + 0.5\n\n\t' +
'Microsoft Excel\n\tERF(LN({0:e} + {1:e}*A1 + {2:e}*(A1^2) + {3:e}*(A1^3) + {4:e}*(A1^4) + {5:e}*(A1^5) + {6:e}*(A1^6) + {7:e}*(A1^7) ))/2 + 0.5\n\n\t' +
'WolframAlpha\n\tplot | erf(log({0:e} + {1:e} x + {2:e} x^2 + {3:e} x^3 + {4:e} x^4 + {5:e} x^5 + {6:e} x^6 + {7:e} x^7 ))/2 + 0.5 | x = 0 to 100\n\n',
'\n\n\tPython\n\tscipy.special.erf(math.log({0:e} + {1:e}*x + {2:e}*(x**2) + {3:e}*(x**3) + {4:e}*(x**4) + {5:e}*(x**5) )) * (0.5 - {7:e}) + 0.5 - {7:e} + {6:e}\n\n\t' +
'\n\n\tPython\n\tfrom scipy.special import erf\n\terf(math.log({0:e} + {1:e}*x + {2:e}*(x**2) + {3:e}*(x**3) + {4:e}*(x**4) + {5:e}*(x**5) )) * (0.5 - {7:e}) + 0.5 - {7:e} + {6:e}\n\n\t' +
'Microsoft Excel\n\tERF(LN({0:e} + {1:e}*A1 + {2:e}*(A1^2) + {3:e}*(A1^3) + {4:e}*(A1^4) + {5:e}*(A1^5) )) * (0.5 - {7:e}) + 0.5 - {7:e} + {6:e}\n\n\t' +
'WolframAlpha\n\tplot | erf(log({0:e} + {1:e} x + {2:e} x^2 + {3:e} x^3 + {4:e} x^4 + {5:e} x^5 )) * (0.5 - {7:e}) + 0.5 - {7:e} + {6:e} | x = 0 to 100\n\n',
'\n\n\tPython\n\tmath.tanh(math.log({0:e} + {1:e}*x + {2:e}*(x**2) + {3:e}*(x**3) + {4:e}*(x**4) + {5:e}*(x**5) + {6:e}*(x**6) + {7:e}*(x**7) ))/2 + 0.5\n\n\t' +
Expand Down Expand Up @@ -166,7 +166,7 @@ def xOverAbsFC(self, x):
'Microsoft Excel\n\t(0.5 - {7:e}) * (LN({0:e} + {1:e}*A1 + {2:e}*(A1^2) + {3:e}*(A1^3) + {4:e}*(A1^4) + {5:e}*(A1^5) + {6:e}*(A1^6) + {7:e}*(A1^7) ) )/(1 + ABS(LN({0:e} + {1:e}*A1 + {2:e}*(A1^2) + {3:e}*(A1^3) + {4:e}*(A1^4) + {5:e}*(A1^5) ))) + 0.5 - {7:e} + {6:e}\n\n\t' +
'WolframAlpha\n\tplot | (0.5 - {7:e}) * log({0:e} + {1:e} x + {2:e} x^2 + {3:e} x^3 + {4:e} x^4 + {5:e} x^5 + {6:e} x^6 + {7:e} x^7)/(1 + abs(log({0:e} + {1:e} x + {2:e} x^2 + {3:e} x^3 + {4:e} x^4 + {5:e} x^5 ))) + 0.5 - {7:e} + {6:e} | x = 0 to 100\n\n' ]

def function(self, x):
def function(self, x) -> float:
return self.testFuncs[self.best](self, x)

def __init__(self, parameters: np.ndarray, functionNumber: int):
Expand Down Expand Up @@ -219,7 +219,7 @@ def reportModel(models: Tuple[bestFit, bestFit]) -> None:

print(text_output)

#Saving the report text file in the same directory
# Saving the report text file in the same directory
with open('report.txt', 'w') as f:
f.write(text_output)

Expand Down Expand Up @@ -263,6 +263,6 @@ def plotModel(models: Tuple[bestFit, bestFit]) -> None:
subpl.set_title(models[0].bestName)
subpl.grid()

#Saving the graph image file in the same directory
# Saving the graph image file in the same directory
fig.savefig("result.png")
plt.show()
7 changes: 4 additions & 3 deletions report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Best fit is:

Python
scipy.special.erf(math.log(1.581612e-31 + 1.705297e-03*x + 4.506091e-05*(x**2) + 8.379151e-20*(x**3) + 4.658006e-22*(x**4) + 7.664785e-104*(x**5) + 3.756644e-108*(x**6) + 3.756644e-113*(x**7) )) * 0.5 + 0.5
from scipy.special import erf
erf(math.log(1.623678e-14 + 3.139786e-03*x + 4.001290e-05*(x**2) + 1.648922e-08*(x**3) + 4.791815e-22*(x**4) + 1.750653e-132*(x**5) + 8.580251e-137*(x**6) + 8.580251e-142*(x**7) )) * 0.5 + 0.5

Microsoft Excel
ERF(LN(1.581612e-31 + 1.705297e-03*A1 + 4.506091e-05*(A1^2) + 8.379151e-20*(A1^3) + 4.658006e-22*(A1^4) + 7.664785e-104*(A1^5) + 3.756644e-108*(A1^6) + 3.756644e-113*(A1^7) ))/2 + 0.5
ERF(LN(1.623678e-14 + 3.139786e-03*A1 + 4.001290e-05*(A1^2) + 1.648922e-08*(A1^3) + 4.791815e-22*(A1^4) + 1.750653e-132*(A1^5) + 8.580251e-137*(A1^6) + 8.580251e-142*(A1^7) ))/2 + 0.5

WolframAlpha
plot | erf(log(1.581612e-31 + 1.705297e-03 x + 4.506091e-05 x^2 + 8.379151e-20 x^3 + 4.658006e-22 x^4 + 7.664785e-104 x^5 + 3.756644e-108 x^6 + 3.756644e-113 x^7 ))/2 + 0.5 | x = 0 to 100
plot | erf(log(1.623678e-14 + 3.139786e-03 x + 4.001290e-05 x^2 + 1.648922e-08 x^3 + 4.791815e-22 x^4 + 1.750653e-132 x^5 + 8.580251e-137 x^6 + 8.580251e-142 x^7 ))/2 + 0.5 | x = 0 to 100

Binary file modified result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b480a44

Please sign in to comment.