correlate#
- class brainunit.math.correlate(a, v, mode='valid', *, precision=None, preferred_element_type=None, unit_to_scale=None, **kwargs)#
Cross-correlation of two 1-dimensional sequences.
This function computes the correlation as generally defined in signal processing texts:
\[c_k = \sum_n a_{n+k} \cdot \overline{v}_n\]with a and v sequences being zero-padded where necessary and \(\overline x\) denoting complex conjugation.
- Parameters:
a (
Union[Array,ndarray,number,bool, saiunit.Quantity]) – Input sequences.v (
Union[Array,ndarray,number,bool, saiunit.Quantity]) – Input sequences.mode (
str) – Refer to the convolve docstring. Note that the default is ‘valid’, unlike convolve, which uses ‘full’.precision (
Any) – the backend, aPrecisionenum value (Precision.DEFAULT,Precision.HIGHorPrecision.HIGHEST), a string (e.g. ‘highest’ or ‘fastest’, see thejax.default_matmul_precisioncontext manager), or a tuple of twoPrecisionenums or strings indicating precision oflhsandrhs.preferred_element_type (
Union[str,type[Any],dtype,SupportsDType,None]) – accumulation type for the input types, or a datatype, indicating to accumulate results to and return a result with that datatype.unit_to_scale (
Optional[saiunit.Unit]) – When provided, both inputs are converted to dimensionless values with this unit before correlating (kept for backwards compatibility). When omitted, units are propagated likeconvolve(): the result unit isa.unit * v.unit.
- Returns:
out – Discrete cross-correlation of a and v. The resulting unit is
a.unit * v.unit.- Return type:
Array