cost_distribution_stats#

caf.distribute.gravity_model.core.cost_distribution_stats(achieved_trip_distribution, cost_matrix, target_cost_distribution=None)#

Generate standard stats for a cost distribution performance.

Parameters:
  • achieved_trip_distribution (ndarray) – The achieved distribution of trips. Must be the same shape as cost_matrix.

  • cost_matrix (ndarray) – A matrix describing the zone to zone costs. Must be the same shape as achieved_trip_distribution.

  • target_cost_distribution (CostDistribution | None) – The cost distribution that achieved_trip_distribution and cost_matrix were aiming to recreate.

Returns:

  • achieved_cost_distribution – The achieved cost distribution produced by achieved_trip_distribution and cost_matrix. If target_cost_distribution is given, this will use the same bins defined, otherwise dynamic bins will be selected.

  • achieved_residuals – The residual difference between achieved_cost_distribution and target_cost_distribution band share values. Will be an array of np.inf if target_cost_distribution is not set.

  • achieved_convergence – A float value between 0 and 1. Values closer to 1 indicate a better convergence. Will be -1 if target_cost_distribution is not set.

Return type:

tuple[CostDistribution, ndarray, float]