pastas.stats.core.ccf ===================== .. py:function:: pastas.stats.core.ccf(x: pandas.Series, y: pandas.Series, lags: pastas.typing.ArrayLike = 365, bin_method: str = 'regular', bin_width: float = 0.5, max_gap: float = inf, min_obs: int = 50, full_output: bool = False, alpha: float = 0.05, fallback_bin_method: str = 'gaussian') -> pandas.Series | pandas.DataFrame Method to compute the cross-correlation for irregular time series. :param x: Pandas Series containing the values to calculate the cross-correlation on. The index has to be a Pandas.DatetimeIndex. :type x: pandas.Series :param y: Pandas Series containing the values to calculate the cross-correlation on. The index has to be a Pandas.DatetimeIndex. :type y: pandas.Series :param lags: numpy array containing the lags in days for which the cross-correlation is calculated. Defaults is all lags from 1 to 365 days. :type lags: array_like, optional :param bin_method: method to determine the type of bin. Options are "regular" for regular data (default), and "gaussian" and "rectangle" for irregular data. :type bin_method: str, optional :param bin_width: number of days used as the width for the bin to calculate the correlation. :type bin_width: float, optional :param max_gap: Maximum timestep gap in the data. All timesteps above this gap value are not used for calculating the average timestep. This can be helpful when there is a large gap in the data that influences the average timestep. :type max_gap: float, optional :param min_obs: Minimum number of observations in a bin to determine the correlation. :type min_obs: int, optional :param full_output: If True, also estimated uncertainties are returned. Default is False. :type full_output: bool, optional :param alpha: alpha level to compute the confidence interval (e.g., 1-alpha). :type alpha: float :param fallback_bin_method: method to determine the type of bin used to compute the correlations if the data has irregular time steps between the measurements. Options are "gaussian" (default) and "rectangle" . :type fallback_bin_method: str, optional :returns: **result** -- If full_output=True, a DataFrame with columns "ccf", "conf", and "n", containing the cross-correlation function, confidence intervals (depends on alpha), and the number of samples n used to compute these, respectively. If full_output=False, only the CCF is returned. :rtype: pandas.Series or pandas.DataFrame .. rubric:: Examples >>> ccf = ps.stats.ccf(x, y, bin_method="gaussian") .. rubric:: Notes The CCF method primarily tries to estimate the correlation using common techniques if the time step between the measurements is regular. If the time step is irregular, the method falls back to an alternative method to calculate the correlation function for irregular timesteps based on the slotting technique :cite:t:`rehfeld_comparison_2011`. Different methods (kernels) to bin the data are available. Estimating the correlation for irregular time steps can be challenging. Depending on the data and the binning method and settings used, the correlation can be above 1 or below -1. If this occurs, a warning is raised. .. !! processed by numpydoc !!