{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.gridspec as gridspec\n",
    "import pandas as pd\n",
    "from scipy.integrate import odeint,quad\n",
    "from scipy.stats import kde,beta\n",
    "import seaborn as sns\n",
    "%matplotlib inline\n",
    "from importlib import reload\n",
    "pi=np.pi\n",
    "\n",
    "#pour matplotlib\n",
    "font = {'weight' : 'bold',\n",
    "        'size'   : 22}\n",
    "\n",
    "plt.rc('font', **font)\n",
    "#plt.rc('text', usetex=True)\n",
    "plt.rc('xtick',labelsize=22)\n",
    "plt.rc('ytick',labelsize=22)\n",
    "\n",
    "#mardi 31 mars 2020\n",
    "#essayons tout d'abord d'écrire des fonctions qui calculent le rayon spectral\n",
    "#et l'abcisse de convergence d'une matrice\n",
    "\n",
    "from numpy import linalg as LA\n",
    "from scipy.linalg import expm\n",
    "from scipy.optimize import brentq\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A more general case that would be worth investigating is the life cycle of Covid19 between Asymptomatic hosts (A) and Symptomatic hosts (S). Only A and S hosts can transmit the infections which may lead to:\n",
    "\\begin{eqnarray}\n",
    "    \\frac{\\mathrm{d}I_A(t)}{\\mathrm{d}t} &=& p_A (\\beta_A(t) I_A(t) + \\beta_S(t) I_S(t))-\\gamma_A(t)I_A(t)\\\\\n",
    "    \\frac{\\mathrm{d}I_S(t)}{\\mathrm{d}t} &=& p_S (\\beta_A(t) I_A(t) + \\beta_S(t) I_S(t))-\\gamma_S(t)I_S(t)\n",
    "\\end{eqnarray}\n",
    "where $p_A+p_S=1$. \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ucovid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'ucovid' from '/home/philippe/pca/EPIDEMIE/ucovid.py'>"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reload(ucovid)\n",
    "#ucovid.siraicov()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ucovid.bsiraicov()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ipywidgets import interact, interactive, fixed, interact_manual\n",
    "import ipywidgets as widgets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "#interact(ucovid.siraicov,betaS=widgets.FloatSlider(min=0.1, max=0.5, step=0.05, value=0.25),nbpts=fixed(50),\n",
    "#        gammaA=widgets.FloatSlider(min=0.01, max=0.25, step=0.01, value=0.1),\n",
    "#         gammaS=widgets.FloatSlider(min=0.01, max=0.25, step=0.01, value=0.05),\n",
    "#        piS=widgets.FloatSlider(min=0.05, max=0.95, step=0.05, value=0.15),\n",
    "#        T=widgets.IntSlider(min=1, max=100, step=1, value=7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ucovid.bsiraicov(T=500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ucovid.bsiraicov(T=7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "#reload(ucovid)\n",
    "#ucovid.bipersiraicov()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3dd7a8b942d5456da37be9e6054f6cfd",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.25, description='betaA', max=0.75, min=-0.25), FloatSlider(value=0.2…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<function ucovid.bipersiraicov>"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "interact(ucovid.bipersiraicov,betaS=widgets.FloatSlider(min=0.1, max=0.5, step=0.05, value=0.25, continuous_update=False),nbpts=fixed(50),\n",
    "        gammaA=widgets.FloatSlider(min=0.01, max=0.25, step=0.01, value=0.1, continuous_update=False),\n",
    "         gammaS=widgets.FloatSlider(min=0.01, max=0.25, step=0.01, value=0.05, continuous_update=False),\n",
    "        piS=widgets.FloatSlider(min=0.05, max=0.95, step=0.05, value=0.15, continuous_update=False),\n",
    "        T1=widgets.IntSlider(min=1, max=10, step=1, value=7, continuous_update=False),\n",
    "        T2=widgets.IntSlider(min=10, max=400, step=10, value=10, continuous_update=False))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}