RandomNet#
- class RandomNet(pars=None, key_dict=None, **kwargs)[source]#
Bases:
DynamicNetwork
Random connectivity between agents
Attributes
beta
Relative transmission on each network edge
members
Return sorted array of all members
now
Shortcut to self.t.now()
p1
The first half of a network edge (person 1)
p2
The second half of a network edge (person 2)
states
Return a flat list of all states
statesdict
Return a flat dictionary (objdict) of all states
ti
Get the current module timestep
timevec
Shortcut to self.t.timevec
Methods
- get_edges(inds, n_contacts)[source]#
Efficiently find edges
Note that because of the shuffling operation, each person is assigned 2N contacts (i.e. if a person has 5 contacts, they appear 5 times in the ‘source’ array and 5 times in the ‘target’ array). Therefore, the number_of_contacts argument to this function should be HALF of the total contacts a person is expected to have, if both the source and target array outputs are used (e.g. for social contacts)
adjusted_number_of_contacts = np.round(number_of_contacts / 2).astype(ss.dtype.int)
Whereas for asymmetric contacts (e.g. staff-public interactions) it might not be necessary
- Parameters:
inds – List/array of person indices
number_of_contacts – List/array the same length as inds with the number of unidirectional
Therefore (contacts to assign to each person.)
number (a person will have on average TWICE this)
contacts. (of random)
Returns: Two arrays, for source and target