powergrid_synth.distribution.distribution_validation
Validation and statistical comparison for synthetic distribution feeders.
Provides KL-divergence computation and emergent property validation against reference feeders, as described in Section IV of Schweitzer et al. (2017).
Module Contents
- powergrid_synth.distribution.distribution_validation.compare_feeders(synthetic, reference)[source]
Compare synthetic and reference feeders via KL-divergence.
Returns a dict mapping distribution name → KL divergence value.
- Parameters:
synthetic (networkx.Graph)
reference (networkx.Graph)
- Return type:
Dict[str, float]
- powergrid_synth.distribution.distribution_validation.compute_emergent_properties(G)[source]
Compute emergent (aggregate) properties of a feeder.
Returns a dict with:
n_nodes: total number of nodesn_edges: total number of edgesmax_hop: maximum hop distancemean_degree: mean node degreetotal_load_mw: sum of positive Ptotal_gen_mw: sum of negative P (absolute)frac_intermediate: fraction of intermediate nodesfrac_injection: fraction of injection nodesmean_length_km: mean cable lengthmax_length_km: maximum cable lengthtotal_length_km: total cable length
- Parameters:
G (networkx.Graph)
- Return type:
Dict[str, float]
- powergrid_synth.distribution.distribution_validation.extract_cable_length_distribution(G, n_bins=50)[source]
Return cable-length histogram (counts, bin_edges).
- Parameters:
G (networkx.Graph)
n_bins (int)
- Return type:
Tuple[numpy.ndarray, numpy.ndarray]
- powergrid_synth.distribution.distribution_validation.extract_degree_distribution(G)[source]
Return degree histogram from a feeder graph.
- Parameters:
G (networkx.Graph)
- Return type:
numpy.ndarray
- powergrid_synth.distribution.distribution_validation.extract_hop_distribution(G)[source]
Return hop-distance histogram from a feeder graph.
- Parameters:
G (networkx.Graph)
- Return type:
numpy.ndarray
- powergrid_synth.distribution.distribution_validation.extract_load_per_node(G)[source]
Return array of non-zero load values (MW).
- Parameters:
G (networkx.Graph)
- Return type:
numpy.ndarray
- powergrid_synth.distribution.distribution_validation.kl_divergence_discrete(p_counts, q_counts, n_bins=None)[source]
Compute KL divergence D_KL(P || Q) for two discrete histograms.
- Parameters:
p_counts (array-like) – Raw counts or probability arrays. They are normalized internally.
q_counts (array-like) – Raw counts or probability arrays. They are normalized internally.
n_bins (int, optional) – Re-bin both arrays into n_bins equally spaced bins.
- Returns:
KL divergence in nats. Returns
infif Q has zero probability where P is nonzero.- Return type:
float