|
| 1 | +import numpy as np |
| 2 | + |
| 3 | + |
| 4 | +class CoreGroupNgm: |
| 5 | + def __init__( |
| 6 | + self, |
| 7 | + num_groups: int, |
| 8 | + r0_matrix: np.ndarray, |
| 9 | + # Other parameters go here |
| 10 | + ): |
| 11 | + self.k = self.make_k(num_groups, r0_matrix) |
| 12 | + # Other parameters get stored here |
| 13 | + raise NotImplementedError() |
| 14 | + |
| 15 | + def make_k(self, num_groups: int, r0_matrix: np.ndarray): |
| 16 | + raise NotImplementedError() |
| 17 | + |
| 18 | + def calculate_r_eff(self) -> float: |
| 19 | + r""" |
| 20 | + Compute $R_e$ |
| 21 | +
|
| 22 | + Returns |
| 23 | + ------- |
| 24 | + float |
| 25 | + $R_e$ via the spectral radius of the next generation matrix |
| 26 | + """ |
| 27 | + # Could consider caching eigenvalues/vectors, but always re-computing feels safer |
| 28 | + eval = np.linalg.eig(self.k).eigenvalues |
| 29 | + # eval at index (via argmax) of maximum absolute value |
| 30 | + # @TODO: do we need to check for imaginary components? |
| 31 | + return eval[np.argmax(np.abs(eval))] |
| 32 | + |
| 33 | + def calculate_infectious_distribution(self) -> np.ndarray: |
| 34 | + r""" |
| 35 | + Compute distribution of infections |
| 36 | +
|
| 37 | + Returns |
| 38 | + ------- |
| 39 | + np.ndarray |
| 40 | + The PMF on infections, I think? |
| 41 | + """ |
| 42 | + # evec = np.linalg.eig(self.k).eigenvectors |
| 43 | + raise NotImplementedError() |
| 44 | + |
| 45 | + def calculate_severe_outcomes(self, inf_dist: np.ndarray): |
| 46 | + r""" |
| 47 | + Compute distribution of severe outcomes from the distribution of infections |
| 48 | +
|
| 49 | + Parameters |
| 50 | + ---------- |
| 51 | + inf_dist : np.ndarray |
| 52 | + Output of self.calculate_infectious_distribution() |
| 53 | +
|
| 54 | + Returns |
| 55 | + ------- |
| 56 | + np.ndarray |
| 57 | + The PMF on severe outcomes, I think? |
| 58 | + """ |
| 59 | + raise NotImplementedError() |
0 commit comments