util.mux¶
-
util.
mux
(seed_pool, n_samples, k, lam=256.0, pool_weights=None, with_replacement=True, prune_empty_seeds=True)[source]¶ Stochastic multiplexor for generator seeds.
Given an array of Streamer objects, do the following:
- Select
k
seeds at random to activate - Assign each activated seed a sample count ~ Poisson(lam)
- Yield samples from the streams by randomly multiplexing from the active set.
- When a stream is exhausted, select a new one from the pool.
Parameters: seed_pool : iterable of Streamer
The collection of Streamer objects
n_samples : int > 0 or None
The number of samples to generate. If
None
, sample indefinitely.k : int > 0
The number of streams to keep active at any time.
lam : float > 0 or None
Rate parameter for the Poisson distribution governing sample counts for individual streams. If
None
, sample infinitely from each stream.pool_weights : np.ndarray or None
Optional weighting for
seed_pool
. IfNone
, then weights are assumed to be uniform. Otherwise,pool_weights[i]
defines the sampling proportion ofseed_pool[i]
.Must have the same length as
seed_pool
.with_replacement : bool
Sample Streamers with replacement. This allows a single stream to be used multiple times (even simultaneously). If
False
, then each Streamer is consumed at most once and never revisited.prune_empty_seeds : bool
Disable seeds from the pool that produced no data. If
True
, Streamers that previously produced no data are never revisited. Note that this may be undesireable for streams where past emptiness may not imply future emptiness.- Select