leniax.statistics package

leniax.statistics.build_compute_stats_fn(world_params, render_params)[source]

Construct the conpute_statistics function

Parameters
  • world_params (Dict) – World parameters dictrionnary.

  • render_params (Dict) – Render parameters dictrionnary.

Returns

The compute statistics function

Return type

Callable

leniax.statistics.check_heuristics(stats)[source]

Check heuristics on statistic data

Parameters

stats (Dict[str, jax._src.numpy.ndarray.ndarray]) – Simulation statistics dictionnary

Returns

An array of boolean value indicating if the heuristics are valid for each timsteps

Return type

jax._src.numpy.ndarray.ndarray

leniax.statistics.init_counters(N)[source]

Initialize different counters used in heuristics decisions

Parameters

N (int) – Number of simulated timesteps

Returns

Adictionnary of counters

Return type

Dict[str, jax._src.numpy.ndarray.ndarray]

leniax.statistics.min_channel_mass_heuristic(epsilon, channel_mass)[source]

Check if a total mass per channel is below the threshold

Parameters
  • epsilon (float) – A very small value to avoid division by zero

  • channel_mass (jax._src.numpy.ndarray.ndarray) – Total mass per channel of shape [N, C]

Returns

A boolean array of shape [N]

Return type

jax._src.numpy.ndarray.ndarray

leniax.statistics.max_channel_mass_heuristic(init_channel_mass, channel_mass)[source]

Check if a total mass per channel is above the threshold

Parameters
  • init_channel_mass (jax._src.numpy.ndarray.ndarray) – Initial mass per channel of shape [N, C]

  • channel_mass (jax._src.numpy.ndarray.ndarray) – Total mass per channel of shape [N, C]

Returns

A boolean array of shape [N]

Return type

jax._src.numpy.ndarray.ndarray

leniax.statistics.min_mass_heuristic(epsilon, mass)[source]

Check if the total mass of the system is below the threshold

Parameters
  • epsilon (float) – A very small value to avoid division by zero

  • mass (jax._src.numpy.ndarray.ndarray) – Total mass of shape [N]

Returns

A boolean array of shape [N]

Return type

jax._src.numpy.ndarray.ndarray

leniax.statistics.max_mass_heuristic(init_mass, mass)[source]

Check if a total mass per channel is above the threshold

Parameters
  • init_mass (jax._src.numpy.ndarray.ndarray) – Initial mass per channel of shape [N]

  • mass (jax._src.numpy.ndarray.ndarray) – Total mass per channel of shape [N]

Returns

A boolean array of shape [N]

Return type

jax._src.numpy.ndarray.ndarray

leniax.statistics.monotonic_heuristic(sign, previous_sign, monotone_counter)[source]

Check if the mass variation is being monotonic for too many timesteps

Parameters
  • sign (jax._src.numpy.ndarray.ndarray) – Current sign of mass variation of shape [N]

  • previous_sign (jax._src.numpy.ndarray.ndarray) – Previous sign of mass variation of shape [N]

  • monotone_counter (jax._src.numpy.ndarray.ndarray) – Counter used to count number of timesteps with monotonic variations of shape [N]

Returns

A tuple representing a boolean array of shape [N] and the counter

Return type

Tuple[jax._src.numpy.ndarray.ndarray, jax._src.numpy.ndarray.ndarray]

leniax.statistics.mass_volume_heuristic(mass_volume, mass_volume_counter)[source]

Check if the mass volume is above the threshold for too manye timesteps

Parameters
  • mass_volume (jax._src.numpy.ndarray.ndarray) – Mass volume of shape [N]

  • mass_volume_counter (jax._src.numpy.ndarray.ndarray) – Counter of shape [N] used to count number of timesteps with a volume above the threshold

Returns

A tuple representing a boolean array of shape [N] and the counter

Return type

Tuple[jax._src.numpy.ndarray.ndarray, jax._src.numpy.ndarray.ndarray]

leniax.statistics.stats_list_to_dict(all_stats)[source]

Change a list of dictionnary in a dictionnary of array

Parameters

all_stats (List[Dict]) – List of 1-timestep statistics dictionary

Returns

A dictionnary of N-timestep array.

Return type

Dict[str, jax._src.numpy.ndarray.ndarray]