biogeme.draws.management module¶
This module defines the Draws class, which manages the generation and conversion of random draws for use in simulation-based models.
Michel Bierlaire Thu Mar 27 08:42:16 2025
- class biogeme.draws.management.DrawsManagement(sample_size, number_of_draws, user_generators=None)[source]¶
Bases:
object
Manages generation of simulation draws and conversion to JAX-compatible format.
- Parameters:
sample_size (int)
number_of_draws (int)
user_generators (dict[str, RandomNumberGeneratorTuple] | None)
- property draws_jax: Array¶
Returns the generated draws as a JAX array. If no draws have been generated, returns an empty JAX array of shape (sample_size, 1, 1).
- Returns:
JAX-compatible array of draws.
- extract_slice(indices)[source]¶
Create a new DrawsManagement instance containing only a subset of draws.
This is useful to maintain consistency across estimation and validation datasets by slicing the original draws array according to the provided indices.
- Parameters:
indices (
Index
) – The indices used to extract the subset of draws.- Return type:
- Returns:
A new DrawsManagement instance containing the sliced draws.
- generate_draws(draw_types, variable_names)[source]¶
Generates random draws using the configured factory.
- Parameters:
draw_types (
dict
[str
,str
]) – Mapping of variable names to draw types.variable_names (
list
[str
]) – List of variable names requiring draws.
- Return type:
None
- Returns:
The generated draws as a NumPy array.