# A Further Improved Algorithm
###### tags: `others`
[TOC]
## The Original



- black - one contact group
- red - susceptible members
- orange - RBT for each age
## The Improved
- compute $A_g=[n_{g,1},\ldots,n_{g,N_{age}}]$ for each contact group $g$ with nonzero $A_g$
- $N_{age}=|Age|$ is the number of age groups
- $n_{g,i}=|\{u\mid u\in I\cap g,age(u)=i\}|$, that is, infected individual $u$ is in the contact group $g$ in this period(so it is attempting to infect susceptible individuals in contact group $g$), and grouped by age
### Algorithm
Given a contact group $g$ with computed $A_g$ and $C=\{c_{i,j}\mid i,j\in Age\}$ be contact matrix(prob from $i$ to $j$)
- let $p_i$ be $1-\prod\limits_{j\in Age}(1-c_{j,i})^{n_{g,j}}$ for $i\in Age$
- randomly choose $B(||)$ members among $g$ of age $i$
### Improvement
e.g.
- only one age, $N_{age}=1$, $c_{i,j}=p$
- $n$ infectors
- then org we have to
- $n$ infection with $K=p|g|$
- cost $np|g|$
- and improved
- one infection with $K=(1-(1-p)^n)|g|\leq (1-(1-np))|g|=np|g|$
- cost less than $np|g|$