utils#

Numerical utilities for running Covasim.

These include the viral load, transmissibility, and infection calculations at the heart of the integration loop.

Functions

sample

Draw a sample from the distribution specified by the input.

get_pdf

Return a probability density function for the specified distribution.

set_seed

Reset the random seed -- complicated because of Numba, which requires special syntax to reset the seed.

n_binomial

Perform multiple binomial (Bernolli) trials

binomial_filter

Binomial "filter" -- the same as n_binomial, except return the elements of arr that succeeded.

binomial_arr

Binomial (Bernoulli) trials each with different probabilities.

n_multinomial

An array of multinomial trials.

poisson

A Poisson trial.

n_poisson

An array of Poisson trials.

n_neg_binomial

An array of negative binomial trials.

choose

Choose a subset of items (e.g., people) without replacement.

choose_r

Choose a subset of items (e.g., people), with replacement.

choose_w

Choose n items (e.g. people), each with a probability from the distribution probs.

true

Returns the indices of the values of the array that are true: just an alias for arr.nonzero()[0].

false

Returns the indices of the values of the array that are false.

defined

Returns the indices of the values of the array that are not-nan.

undefined

Returns the indices of the values of the array that are not-nan.

itrue

Returns the indices that are true in the array -- name is short for indices[true]

ifalse

Returns the indices that are true in the array -- name is short for indices[false]

idefined

Returns the indices that are defined in the array -- name is short for indices[defined]

iundefined

Returns the indices that are undefined in the array -- name is short for indices[undefined]

itruei

Returns the indices that are true in the array -- name is short for indices[true[indices]]

ifalsei

Returns the indices that are false in the array -- name is short for indices[false[indices]]

idefinedi

Returns the indices that are defined in the array -- name is short for indices[defined[indices]]

iundefinedi

Returns the indices that are undefined in the array -- name is short for indices[defined[indices]]