MCPcopy Index your code
hub / github.com/numpy/numpy / correlate

Function correlate

numpy/ma/core.py:8371–8427  ·  view source on GitHub ↗

Cross-correlation of two 1-dimensional sequences. Parameters ---------- a, v : array_like Input sequences. mode : {'valid', 'same', 'full'}, optional Refer to the `np.convolve` docstring. Note that the default is 'valid', unlike `convolve`, which uses '

(a, v, mode='valid', propagate_mask=True)

Source from the content-addressed store, hash-verified

8369
8370
8371def correlate(a, v, mode='valid', propagate_mask=True):
8372 """
8373 Cross-correlation of two 1-dimensional sequences.
8374
8375 Parameters
8376 ----------
8377 a, v : array_like
8378 Input sequences.
8379 mode : {'valid', 'same', 'full'}, optional
8380 Refer to the `np.convolve` docstring. Note that the default
8381 is 'valid', unlike `convolve`, which uses 'full'.
8382 propagate_mask : bool
8383 If True, then a result element is masked if any masked element contributes
8384 towards it. If False, then a result element is only masked if no non-masked
8385 element contribute towards it
8386
8387 Returns
8388 -------
8389 out : MaskedArray
8390 Discrete cross-correlation of `a` and `v`.
8391
8392 See Also
8393 --------
8394 numpy.correlate : Equivalent function in the top-level NumPy module.
8395
8396 Examples
8397 --------
8398 Basic correlation:
8399
8400 >>> a = np.ma.array([1, 2, 3])
8401 >>> v = np.ma.array([0, 1, 0])
8402 >>> np.ma.correlate(a, v, mode='valid')
8403 masked_array(data=[2],
8404 mask=[False],
8405 fill_value=999999)
8406
8407 Correlation with masked elements:
8408
8409 >>> a = np.ma.array([1, 2, 3], mask=[False, True, False])
8410 >>> v = np.ma.array([0, 1, 0])
8411 >>> np.ma.correlate(a, v, mode='valid', propagate_mask=True)
8412 masked_array(data=[--],
8413 mask=[ True],
8414 fill_value=999999,
8415 dtype=int64)
8416
8417 Correlation with different modes and mixed array types:
8418
8419 >>> a = np.ma.array([1, 2, 3])
8420 >>> v = np.ma.array([0, 1, 0])
8421 >>> np.ma.correlate(a, v, mode='full')
8422 masked_array(data=[0, 1, 2, 3, 0],
8423 mask=[False, False, False, False, False],
8424 fill_value=999999)
8425
8426 """
8427 return _convolve_or_correlate(np.correlate, a, v, mode, propagate_mask)
8428

Callers

nothing calls this directly

Calls 1

_convolve_or_correlateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…