1、Matlab

直接调用函数awgn: https://ww2.mathworks.cn/help/comm/ref/awgn.html#mw_c6871974-86ae-4fe3-a574-c5c7da623e38

 

2、Python

def awgn(signal, desired_snr, signal_power):
    """
    Add AWGN to the input signal to achieve the desired SNR level.
    """
    # Calculate the noise power based on the desired SNR and signal power
    noise_power = signal_power / (10**(desired_snr / 10))
    
    # Generate the noise with the calculated power
    noise = np.random.normal(0, np.sqrt(noise_power), len(signal))
    
    # Add the noise to the original signal
    noisy_signal = signal + noise
    
    return noisy_signal

 

为什么高斯白噪声的平均功率等于方差?(https://translate.google.com/?hl=zh-CN&sl=auto&tl=zh-CN&op=translate)

 参考:https://saturncloud.io/blog/python-numpy-implementing-an-additive-white-gaussian-noise-function/
posted on 2023-10-01 21:17  clayyjh  阅读(272)  评论(0)    收藏  举报