displacement

nomad.displacement.normalize_od(data, origin_col, dest_col, weight_col, diff_privacy_eps=None, seed=None)[source]

Convert an origin–destination table to percentages (share of total trips) with optional Laplace DP noise. :param data: :type data: pandas DataFrame, OD table. :param origin_col: :type origin_col: str, column with origin geography. :param dest_col: :type dest_col: str, column with destination geography. :param weight_col: :type weight_col: str, column with trip counts (non-negative ints). :param diff_privacy_eps: privacy budget ε; if None, return exact percentages. :type diff_privacy_eps: float or None. If set, add Laplace noise with :param seed: :type seed: optional int for reproducibility when ε is given.

Returns:

  • pandas DataFrame with columns – [origin_col, dest_col, ‘percentage’]

  • where ‘percentage’ sums to 100.

nomad.displacement.normalized_moved(data, origin_col, dest_col, weight_col, diff_privacy_eps=None, seed=None)[source]

Normalised list of moving OD flows (origin ≠ destination) with optional DP noise. :param data: :type data: see normalize_od. :param origin_col: :type origin_col: see normalize_od. :param dest_col: :type dest_col: see normalize_od. :param weight_col: :type weight_col: see normalize_od. :param diff_privacy_eps: :type diff_privacy_eps: float or None. ε for DP; None for exact values. :param seed: :type seed: optional int.

Returns:

[origin_col, dest_col, ‘percentage’] whose percentages sum to 100.

Return type:

pandas DataFrame with columns

nomad.displacement.normalized_remained(data, origin_col, dest_col, weight_col, diff_privacy_eps=None, seed=None)[source]

Percentage of trips that remain in the origin geography, with optional per-origin Laplace DP noise. Each origin contributes a single row; percentages are computed relative to that origin’s total outgoing trips. :param data: :type data: see normalize_od. :param origin_col: :type origin_col: see normalize_od. :param dest_col: :type dest_col: see normalize_od. :param weight_col: :type weight_col: see normalize_od. :param diff_privacy_eps: :type diff_privacy_eps: float or None. ε for DP; None for exact values. :param seed: :type seed: optional int.

Returns:

[origin_col, ‘percentage’].

Return type:

pandas DataFrame with columns