Private function intended to insert a new RR interval in the buffer.

    ----------
    Parameters
    ----------
    peak : int
        Sample where the peak under analysis is located.
    amp : int
        Amplitude of the peak under analysis.
    definitive_peaks : list
        List with the definitive_peaks stored until the present instant.
    spk1 : float
        Actual value of SPK1 parameter defined in Pan-Tompkins real-time R peak detection algorithm
        (named signal peak).
    rr_buffer : list
        Data structure that stores the duration of the last eight RR intervals.

    Returns
    -------
    definitive_peaks_out : list
        Definitive peaks list.
    spk1 : float
        Updated value of SPK1 parameter.
    rr_buffer : list
        Buffer after appending a new RR interval and excluding the oldest one.

def _acceptpeak(peak, amp, definitive_peaks, spk1, rr_buffer):
    """
    Private function intended to insert a new RR interval in the buffer.

    ----------
    Parameters
    ----------
    peak : int
        Sample where the peak under analysis is located.
    amp : int
        Amplitude of the peak under analysis.
    definitive_peaks : list
        List with the definitive_peaks stored until the present instant.
    spk1 : float
        Actual value of SPK1 parameter defined in Pan-Tompkins real-time R peak detection algorithm
        (named signal peak).
    rr_buffer : list
        Data structure that stores the duration of the last eight RR intervals.

    Returns
    -------
    definitive_peaks_out : list
        Definitive peaks list.
    spk1 : float
        Updated value of SPK1 parameter.
    rr_buffer : list
        Buffer after appending a new RR interval and excluding the oldest one.

    """

    definitive_peaks_out = definitive_peaks
    definitive_peaks_out = numpy.append(definitive_peaks_out, peak)
    spk1 = 0.125 * amp + 0.875 * spk1  # spk1 is the running estimate of the signal peak
    if len(definitive_peaks_out) > 1:
        rr_buffer.pop(0)
        rr_buffer += [definitive_peaks_out[-1] - definitive_peaks_out[-2]]

    return numpy.array(definitive_peaks_out), spk1, rr_buffer