Exponential vs. Logestic Graphs

In [1]:
import numpy as np
%matplotlib inline
from matplotlib import pyplot as plt
In [2]:
def sigmoid(x, L=1, k=1, x0=0):
    return L/ (1 + np.exp(-k * (x-x0)))
In [3]:
x = np.arange(30*12)

# no intervention
y1 = sigmoid(x, L=24, k=0.05,x0=130)

# flattent the curve?
y2 = sigmoid(x, L=10, k=0.05,x0=170)

# flattent the curve 2?
y3 = sigmoid(x, L=10, k=0.05,x0=200)

# exponential
plt.title("You think you are watching an exponential graph")
plt.plot(x[25:100], y1[25:100], label="no intervention")
plt.xticks([30, 60, 90, ], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',])
plt.yticks([1,2,3,4])
plt.ylabel("daily hours looking at exponential graphs")
plt.show()


# logestic0
plt.title("You realise you are watching a logestic graph")
plt.plot(x[25:30*6+5], y1[25:30*6+5], label="no intervention")
plt.xticks([30, 60, 90, 120, 150, 180], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',])
plt.yticks([ 4, 8, 12, 16, 20, 24, ])
plt.ylabel("daily hours looking at logistic graphs")
plt.show()


# logestic
plt.title("You should flatten the curve")
plt.plot(x[25:30*10+5], y1[25:30*10+5], label="no intervention")
plt.plot(x[25:30*10+5], y2[25:30*10+5], label="flatten your screen time curve earlier")
plt.plot(x[25:30*10+5], np.concatenate([y1[25:120], y1[25:120][-1]*np.ones(30*10+5-120)])+y3[25:30*10+5], label="flatten your screen time curve now")
plt.xticks(np.arange(30, 30*10+5, 30), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',])
plt.yticks([ 4, 8, 12, 16, 20, 24, ])
plt.ylabel("daily hours looking at logistic graphs")
plt.legend()
plt.show()
In [ ]: