plot_udrnrt.c , enter number of samples: you have selected 1000000 samples enter 1 for uniformly distributed: or 2 for gauss distributed: or 3 for gausse distributed: or 4 for sine wave: you have selected a sine wave computed min=-1.000000, max=1.000000, mean=-0.000000, sigma=0.707107 total power=500000, avg power per sample=0.500000 plot_udrnrt.c about to run gnuplot on udrnrt.plot For simulations where a Signal to Noise Ratio , SNR, is specified in decibels, db, the calculations needed to get the specified random noise are: db = 10*log10(P1/P2) P1 is signal power, P2 is noise power remember, the log of a value less that one is negative. A few values of db are shown for signal power equal 1.0 . SNR db 60 db noise power is 10^-6 (1/1000000) 30 db noise power is 10^-3 (1/1000) 20 db noise power is 0.01 10 db noise power is 0.1 3 db noise power is about 1/2 0 db noise power is equal to signal power -3 db noise power is 2 -10 db noise power is 10 -20 db noise power is 100 -30 db noise power is 10^3 (1000) -60 db noise power is 10^6 (1000000) Think of the measured sample of signal or noise as being voltage. Power is voltage squared. Mathematically, the statistic sigma is the Root Mean Square, RMS, value of voltage. The statistic variance=sigma squared, is RMS squared, the value of power. These are the average value of a measured sample. Now given a signal with known or measured RMS or sigma, Ss. Given a specified SNR, Ps compute the sigma needed for a noise that will be added, sample by sample to the signal, and produce the specified SNR: We need to find noise power Pn = Sn^2 SNR = 10*log10(Ss^2/Sn^2) using algebra SNR/10 = log10(Ss^2)-log10(Sn^2) log10(Sn^2) = log10(Ss^2)-SNR/10 Sn^2 = 10^(log10(Ss^2)-SNR/10) use your calculator carefully Sn = sqrt(Ps^2) the sigma to use to generate random noise. Use a mean of 0.0 for the noise, assuming the mean of your signal is about 0.0 . Sample computations: a sine wave, 1.0*sin(t) has a sigma of 0.7071, variance of 0.5. What is the sigma of noise to give an SNR of -20? Sn=sqrt(10^(log10(0.5)-(-20/10)) Sn=sqrt(10^(-0.301 + 2.0)) Sn=sqrt(10^1.699) Sn=sqrt(50) this says the noise power is 50 for signal power 0.5 thus -20 db as expected Sn=7.07 = sigma of noise, with mean 0.0 for this case. Simplified calculation Sn = sqrt(noise power for SNR/signal power) It is claimed that most noise is Gaussian, yet if there is clipping, the noise can have a more uniform distribution. To get a zero mean for udrnrt use 2.0*udrnrt()-1.0. This has a sigma of 0.577, variance = power = 0.333 To get a sine wave with -10db SNR uniform noise, compute noise power for -10db is 10 Sn = sqrt(10/0.333) = 5.477 a voltage ratio, thus generate noise using 5.477*(2.0*udrnrt()-1.0) add the noise, sample by sample, use the samples in your simulation or analysis.