mathematics

A module containing mathematical functions

MDMC.common.mathematics.correlation(input1, input2=None, normalise=False) ndarray[source]

The correlation of two vectors

The Fast Correlation Algorithm (FCA) is utilised. If only a single input is provided, the autocorrelation is calculated.

Parameters:
  • input1 (numpy.ndarray) – A 1D array of data.

  • input2 (numpy.ndarray, optional) – A 1D array of data. If None, autocorrelation of input1 is calculated. Default is None.

  • normalise (bool, optional) – If True, the correlation is normalised at each point to the number of contributions to that point. Default is False.

Returns:

A 1D array of the same length as the input1 containing the correlation between input1 and input2 (or autocorrelation of input1 if input2 is None)

Return type:

numpy.ndarray

MDMC.common.mathematics.faster_autocorrelation(input1: ndarray, weights: ndarray | float = None) ndarray[source]

The autocorrelation of a vector.

The Fast Correlation Algorithm (FCA) is utilised.

Parameters:

input1 (numpy.ndarray) – A 1D array of data.

Returns:

A 1D array of the same length as the input1 containing the correlation between input1 and input2 (or autocorrelation of input1 if input2 is None)

Return type:

numpy.ndarray

MDMC.common.mathematics.faster_correlation(input1, input2) ndarray[source]

The correlation of two vectors.

The Fast Correlation Algorithm (FCA) is utilised.

Parameters:
  • input1 (numpy.ndarray) – A 1D array of data.

  • input2 (numpy.ndarray, optional) – A 1D array of data. If None, autocorrelation of input1 is calculated. Default is None.

Returns:

A 1D array of the same length as the input1 containing the correlation between input1 and input2 (or autocorrelation of input1 if input2 is None)

Return type:

numpy.ndarray