blue_sampler.sample_tessels

blue_sampler.sample_tessels(N=32768, D=2, targets=None, return_atoms=False)[source]

Recursively split the unit square into N random quadrilaterals.

If targets is None, splits are computed to achieve equal areas. If targets is provided, splits are computed to achieve a median separation of the atoms.

Parameters:
  • N (int) – Number of final tessels. Must be a power of 2.

  • targets (NDArray | None) – Coordinates of atoms to split, in the [0, 1)^2 unit box. K must be a multiple of N. The more targets provided, the better the approximation, but the slower the computation (K/N should be at least 100 for a decent tessellation). A typical use case is adaptive tessellation, e.g. with targets being i.i.d. points sampled from a target density.

Return type:

NDArray | tuple[NDArray, NDArray]

Returns:

  • quad (ndarray of shape (N, 4, 2)) – A tessellation composed of N quadrilaterals with equal area or equal number of atoms.

  • atoms (ndarray of shape (N, K/N, 2)) – The input target atoms, redistributed among their final quadrilateral. Only returned if targets was provided and return_atoms is set to True.

Notes

Only supports 2D geometry and a power-of-two number of tessels (N).