# How to generate AWGN with given power spectral density

I am a little unsure about the generation of a additive white Gaussian noise, so I would appreciate to hear from you if Im doing it correctly.

My goal is to generate the time-domain noise correspondent to a noise floor of -135 dbm/Hz

The procedure Im adopting is the following:

1 - Convert the noise floor in dbm/Hz to Watts/Hz
2 - Get the average total power from the PSD.
3 - Generate the Gaussian noise with this average total power
4 - Take the FFT of the Gaussian noise and estimate the periodogram to verify whether it is indeed generating the noise with the correct PSD

Here is how I do the 4 steps above:

1 - \begin{align} S_\text{watts} = \left(10^{\frac{S_\text{dBm}}{10}}\right)10^{-3} \end{align} where $S_\text{watts}$ is the PSD in Watts/Hz and $S_\text{dBm}$ is the PSD in dBm/Hz.

2 - Average total power is given by $$P_n = S_\text{watts} B ,$$ where $B$ is the Bandwidth

3 - Generate the randn MATLAB function multiplied by $\sqrt{P_n}$.

4 -
4.1 Take the FFT of the signal, lets say, $X(k)$.
4.2 Get the Energy Spectral Density (ESD) as $\frac{\left| X(k) \right|^2}{N}$
4.3 Get the PSD by simply dividing the ESD by $N$ (the FFT length) 4.4 I do not simply plot the $10 \log_{10}\left(\text{PSD} 10^3\right)$, since I believe this would plot the PSD in dBm/subcarrier. Instead of this, I plot $10 \log_{10}\left(\frac{\text{PSD}}{\text{tone spacing}} 10^3\right)$, in attempt to get the plot as dBm/Hz.

The code below is what I am using. Please, indicate if Im doing any mistake.

clear all
clc

bandwidth = 106e6;                          % in Hz
sampleFrequency = 2*bandwidth;              % in Hz
noiseFloor = -135;                          % in dBm/Hz
awgnPsd = (10.^(noiseFloor/10))*1e-3;       % in Watts/Hz
noisePower = awgnPsd*2*bandwidth;           % in Watts

% Generate noise signal:
N = 4096;           % signal length
nSymbols = 1000;     % number of symbols with length N to be generated
noise = randn(N,nSymbols)*sqrt(noisePower);

% Verify PSD
toneSpacing = sampleFrequency/N;        % DFT tone spacing
ESD = mean(abs(fft(noise,N)).^2)/N;     % Energy spectral density
PSD = ESD/N;

% plot PSD
figure
plot(10*log10((PSD/toneSpacing)*1e3))

• An aside: if you want to create a discrete-time simulation of a voltage waveform that represents some power level, you need to take the impedance that the voltage is measured across into account. For RF communication applications, this is often 50 ohms. – Jason R Dec 8 '13 at 2:16

Here is a Matlab snippet that might help. You should be able to apply the result to your favorite PSD routine to see the dbm/Hz in the frequency domain.

% create complex noise with a desired dBm/Hz
fs=1e6;             % whatever you want
N=1e5;              % # samples of noise
R=50;               % ohms
dbm_hz = -135;      % goal
bw = fs;            % complex noise with BW = sample rate
dbm = dbm_hz + 10*log10(bw);
dbw = dbm - 30;
watts = 10^(dbw/10);
vrms = sqrt(watts * R);
n = randn(N,1) + j*randn(N,1);
n = vrms * n / std(n);
meas_dbm_hz = 10*log10(sqrt(mean(n.*conj(n)))^2 / R) - 10*log10(bw) + 30