SignedMeasure

class telescopic.SignedMeasure(atoms, weights, replicate, n_replicates)

The signed measures \(\hat\pi_r\) of \(R\) replicates.

\[\hat\pi_r(h) = \sum_{i : \mathrm{replicate}_i = r} \omega_i\,h(x_i)\]

Each replicate’s weights sum to 1. Some are negative, so an estimate can fall outside the range of \(h\).

The arrays are checked at construction and stored as read-only views, without a copy: the attributes cannot be written to, but the arrays passed in still can.

Attributes:
atomsndarray, shape (N, d)
weightsndarray, shape (N,)
replicatendarray of int, shape (N,)

The position, from 0 to R - 1, of the replicate each atom belongs to, in nondecreasing order, so that each replicate’s atoms are consecutive.

n_replicatesint
mass(cell, n_cells)

Each replicate’s signed mass in each of n_cells cells, such as histogram bins.

Parameters:
cellndarray of int, shape (N,)

The cell of each atom, from 0 to n_cells - 1, or -1 for none.

n_cellsint

The number of cells.

Returns:
scipy.sparse.csr_array, shape (R, n_cells)

At most one stored entry per atom, so its memory follows the atoms, not R * n_cells.

per_replicate(h)

The values \(\hat\pi_r(h)\) of each replicate.

Parameters:
hcallable()

Maps atoms of shape (n, d) to values of shape (n,) or (n, p).

Returns:
ndarray, shape (R,) or (R, p)

Notes

Cost: one call of h on all \(N\) atoms, then one sparse product.