poisson_criterion#

cbclib.bin.poisson_criterion(x: numpy.ndarray, ij: numpy.ndarray, shape: Tuple[int, int], I0: numpy.ndarray, bgd: numpy.ndarray, xtal_bi: numpy.ndarray, prof: numpy.ndarray, fidxs: numpy.ndarray, idxs: numpy.ndarray, hkl_idxs: numpy.ndarray, oidxs: Optional[numpy.ndarray] = None, num_threads: int = 1)[source]#

Calculate the Poisson negative log likelihood that the measured intensities I0 are explained by the current estimate of crystal structure factors x and sample projection maps xtal_bi.

Parameters

Notes

The intensity profile \(I_{hkl}(\mathbf{x})\) of a particular Bragg reflection captured on the detector is given by:

\[I_{hkl}(\mathbf{x}) = |q_{hkl}|^2 \chi(\mathbf{u}(\mathbf{x})) f^2_{hkl}(\mathbf{x})\]

where \(q_{hkl}\) are the structure factors and \(\chi(\mathbf{u}(\mathbf{x}))\) are the projection maps of the sample, and \(f_{hkl}(\mathbf{x})\) are the standard reflection profiles.

The Poisson negative log likelihood crietion is given by:

\[\epsilon^{NLL} = \sum_{ni} \log \mathrm{P}(I_n(\mathbf{x}_i), I_{hkl}(\mathbf{x}_i) + I_{bgd}(\mathbf{x}_i)),\]

where the likelihood \(\mathrm{P}\) follows the Poisson distribution \(\log \mathrm{P}(I, \lambda) = I \log \lambda - I\).

Returns

Negative log likelihood and gradient arrays.

Return type

Tuple[numpy.ndarray, numpy.ndarray]