I have a square-ware signal with 1V peak-to-peak (alternating between -500 and +500mV, so its absolute value is a constant 500mV) and I would like to add to this an AWGN expressed in dBc ("decibels relative to the carrier").
How I should generate such normal distribution noise?
I got a hint that - for e.g. -40dBc - the following code would work:
normal(0, (m.pow(10, (-40 / 20)) / 2), ..)
However this ends up generating a lower dBc value (around -31 dBc), meaning "stronger" noise than expected.
Reading around made me find the description of "half-normal distribution", which states that the expected absolute value scales not with sigma, but with sigma*sqrt(2/pi). I tried the following code - and it does seem to work - but I would like to ask for your kind input on whether my thinking was correct and if this code is the appropriate one:
normal(0, (m.pow(10, (-40 / 20)) / 2 / m.sqrt(2 / m.pi)), ..)
The way I calculated effective dBc was this:
- Integrate carrier (in this case it is t*0.5 [V] <- let us call this a
- Integrate the output of normal() <- let us call this b
- Calculate 20 * log10(b / a)
- The code sniplets above are Python-like
- The "/ 2" is there as my carrier is 1V peak-to-peak