distribution_metrics

distribution_metrics.py

Unified module for distribution comparison, kernel metrics, information-theoretic losses, and entropy-regularized optimal transport.

Callable as:

from distribution_metrics import DistributionMetrics as DM

Classes

DistributionMetrics

Stateless utility namespace for:

Module Contents

class DistributionMetrics

Stateless utility namespace for: - Kernel-based metrics (RBF, MMD) - Information-theoretic divergences (KL) - Bitstring / probability utilities - Sinkhorn (entropy-regularized OT) distance

static rbf_kernel(x, y, gamma)
static compute_kernel_matrix(space, gammas)
Parameters:
Return type:

numpy.ndarray

static kernel_expectation(px, py, kernel_matrix)
Parameters:
Return type:

float

static mmd_loss(px, py, kernel_matrix)
Parameters:
Return type:

float

static kl_divergence(p, q, eps=1e-12)
Parameters:
Return type:

float

static safe_log(x, eps=1e-12)
Parameters:
Return type:

numpy.ndarray

static normalize_probs(probs)
Parameters:

probs (numpy.ndarray)

Return type:

numpy.ndarray

static int_to_bitstring(n, length)
Parameters:
Return type:

str

static bitstring_to_int(bitstring)
Parameters:

bitstring (str)

Return type:

int

static probs_to_bitstrings(prob_vector, threshold=1e-06)
Parameters:
Return type:

list

static compute_chi(samples, valid_bitstrings)
Parameters:
  • samples (list)

  • valid_bitstrings (list)

Return type:

float

static sinkhorn_kernel(cost_matrix, epsilon)
Parameters:
Return type:

numpy.ndarray

static build_cost_matrix(space)
Parameters:

space (numpy.ndarray)

Return type:

numpy.ndarray

static sinkhorn_loss(p, q, space=None, epsilon=0.05, max_iter=200, tol=1e-09)
Parameters:
Return type:

float

static sinkhorn_report(p, q, epsilon=0.05)
Parameters:
Return type:

float