Stay organized with collections Save and categorize content based on your preferences.

Computes p.fldj(x, ndims) - q.fdlj(y, ndims), numerically stably.

p_kwargs and q_kwargs are passed to the registered fldj_ratio_fn. The fallback implementation passes them to the forward_log_det_jacobian methods of p and q.

p A bijector instance.
x A tensor from the preimage of p.forward.
q A bijector instance of the same type as p, with matching shape.
y A tensor from the preimage of q.forward.
event_ndims The number of right-hand dimensions comprising the event shapes of x and y.
p_kwargs Keyword args to pass to p.
q_kwargs Keyword args to pass to q.

fldj_ratio log ((abs o det o jac p)(x) / (abs o det o jac q)(y)), i.e. in TFP code, p.forward_log_det_jacobian(x, event_ndims) - q.forward_log_det_jacobian(y, event_ndims). In some cases this will be computed with better than naive numerical precision, e.g. by moving differences inside of a sum reduction.