bilby.core.utils.samples.reflect

bilby.core.utils.samples.reflect(u)[source]

Iteratively reflect a number until it is contained in [0, 1].

This is for priors with a reflective boundary condition, all numbers in the set u = 2n +/- x should be mapped to x.

For the + case we just take u % 1. For the - case we take 1 - (u % 1).

E.g., -0.9, 1.1, and 2.9 should all map to 0.9.

Parameters:
u: array-like

The array of points to map to the unit cube

Returns:
u: array-like

The input array, modified in place.