carpet/datasets.py
def add_gaussian_noise(signal, snr, random_state=None):
    """ Add a Gaussian noise to inout signal to output a noisy signal with the
    targeted SNR.

    Parameters
    ----------
    signal : array, the given signal on which add a Guassian noise.
    snr : float, the expected SNR for the output signal.
    random_state :  int or None (default=None),
        Whether to impose a seed on the random generation or not (for
        reproductability).

    Return
    ------
    noisy_signal : array, the noisy produced signal.
    noise : array, the additif produced noise.
    """
    # draw the noise
    rng = check_random_state(random_state)
    s_shape = signal.shape
    noise = rng.randn(*s_shape)
    # adjuste the standard deviation of the noise
    true_snr_num = np.linalg.norm(signal)
    true_snr_deno = np.linalg.norm(noise)
    true_snr = true_snr_num / (true_snr_deno + np.finfo(np.float).eps)
    std_dev = (1.0 / np.sqrt(10**(snr/10.0))) * true_snr
    noise = std_dev * noise
    noisy_signal = signal + noise
    return noisy_signal, noise
 Add a Gaussian noise to inout signal to output a noisy signal with the
    targeted SNR.

    Parameters
    ----------
    signal : array, the given signal on which add a Guassian noise.
    snr : float, the expected SNR for the output signal.
    random_state :  int or None (default=None),
        Whether to impose a seed on the random generation or not (for
        reproductability).

    Return
    ------
    noisy_signal : array, the noisy produced signal.
    noise : array, the additif produced noise.
    
Add a Gaussian noise to inout signal to output a noisy signal with the
targeted SNR.

Parameters

signal : array, the given signal on which add a Guassian noise.
snr : float, the expected SNR for the output signal.
random_state :  int or None (default=None),
Whether to impose a seed on the random generation or not (for
reproductability).

Return

noisy_signal : array, the noisy produced signal.
noise : array, the additif produced noise.
Add a Gaussian noise to inout signal to output a noisy signal with the targeted SNR . Parameters signal : array the given signal on which add a Guassian noise . snr : float the expected SNR for the output signal . random_state : int or None ( default = None ) Whether to impose a seed on the random generation or not ( for reproductability ) . Return noisy_signal : array the noisy produced signal . noise : array the additif produced noise .
def add_gaussian_noise(signal, snr, random_state=None):
    rng = check_random_state(random_state)
    s_shape = signal.shape
    noise = rng.randn(*s_shape)
    true_snr_num = np.linalg.norm(signal)
    true_snr_deno = np.linalg.norm(noise)
    true_snr = true_snr_num / (true_snr_deno + np.finfo(np.float).eps)
    std_dev = (1.0 / np.sqrt(10**(snr/10.0))) * true_snr
    noise = std_dev * noise
    noisy_signal = signal + noise
    return noisy_signal, noise
def add_gaussian_noise ( signal , snr , random_state = None ) : rng = check_random_state ( random_state ) s_shape = signal . shape noise = rng . randn ( * s_shape ) true_snr_num = np . linalg . norm ( signal ) true_snr_deno = np . linalg . norm ( noise ) true_snr = true_snr_num / ( true_snr_deno + np . finfo ( np . float ) . eps ) std_dev = ( 1.0 / np . sqrt ( 10 ** ( snr / 10.0 ) ) ) * true_snr noise = std_dev * noise noisy_signal = signal + noise return noisy_signal , noise
Add a Gaussian noise to inout signal to output a noisy signal with the
targeted SNR.
Add a Gaussian noise to inout signal to output a noisy signal with the targeted SNR .
""" Add a Gaussian noise to inout signal to output a noisy signal with the
    targeted SNR.

    Parameters
    ----------
    signal : array, the given signal on which add a Guassian noise.
    snr : float, the expected SNR for the output signal.
    random_state :  int or None (default=None),
        Whether to impose a seed on the random generation or not (for
        reproductability).

    Return
    ------
    noisy_signal : array, the noisy produced signal.
    noise : array, the additif produced noise.
    """ # draw the noise # adjuste the standard deviation of the noise
signal
snr
random_state