gigablochs.bloch.labelling_efficiency#
- gigablochs.bloch.labelling_efficiency(long_mag_inverted, long_mag_control=1)[source]#
Compute the labeling efficiency from inverted and control longitudinal magnetizations.
- Parameters:
long_mag_inverted (array_like or float) – Longitudinal magnetization measured in the inverted (label) condition. May be a scalar or an array; if an array, it must be broadcastable with long_mag_control.
long_mag_control (array_like or float, optional) – Longitudinal magnetization measured in the control condition (default: 1). May be a scalar or an array; if an array, it must be broadcastable with long_mag_inverted.
- Returns:
efficiency – The absolute labeling efficiency computed element-wise as
|long_mag_control - long_mag_inverted| / |2 * long_mag_control|. The return has the same shape as the broadcasted inputs. For physically meaningful inputs, values typically lie in [0, 1].- Return type:
float or ndarray
Notes
If long_mag_control is zero, the result is undefined (division by zero). When using NumPy, this will produce inf or nan values and may emit a runtime warning.
This function does not validate input types beyond relying on NumPy broadcasting semantics; pass numeric scalars or array-like objects.
Examples
>>> labelling_efficiency(0.2) 0.4 >>> labelling_efficiency(np.array([0.9, 0.8, 0, -0.9, -1])) array([0.05, 0.1, 0.5, 0.95, 1. ])