flow_utilities

This file contains a set of utilities operating on flows.

tensiometer.synthetic_probability.flow_utilities.KL_divergence(flow_1, flow_2, num_samples=1000, num_batches=100)[source]

Calculates the Kullback-Leibler (KL) divergence between two flows:

D_KL(flow_1 || flow_2) = E_{x ~ flow_1} [log(flow_1(x)) - log(flow_2(x))]

Parameters: flow_1 (Flow): The flow for the sampling distribution. flow_2 (Flow): The second flow distribution. num_samples (int): The number of samples to draw from the flows, per batch. Default is 1000. num_batches (int): The number of batches to run. Default is 100.

Returns: mean (float): The mean KL divergence. std (float): The standard deviation of the KL divergence.