The decibel is used in a wide range of applications. Decibels are especially used, when a referring to power or a derived measure, which values can vary in a wide range. The most prominent usage of decibels is in sound volume. So, for example a sound of 0dB is barely hearable, whereas a vaccum cleaner on average has 75dB and a rock concert reaches about 110dB.
In class, you often find the following definitions for something in decibels
$$X_{dB}=10\log_{10}\left(\frac{X_{lin}}{X_{ref}}\right).$$This equation transforms quantity $X_{lin}$ from linear scale to a quantity in dB scale $X_{dB}$. In order to do that, first the linear quantity is related to a reference quantity $X_{ref}$ and the ratio of both is transformed into the log-domain. Apparently, $X_{dB}$ does actually have no unit and we artificially add dB to make clear we are in logarithmic scale. When $X_{lin}$ equals the reference level, the dB-scale becomes zero:
$$X_{dB}=10\log_{10}\left.\left(\frac{X_{lin}}{X_{ref}}\right)\right|_{X_{lin}=X_{ref}}=0dB.$$Furthermore, when $X_{lin}>X_{ref}$, $X_{dB}$ is positive and if $X_{lin} So far, so good. But, on the other hand, more often than not, you also see the following definition: i.e. the factor before the logarithm is 20 instead of 10. Which version is correct? Both formulas are correct, but you need to take care when you use which formula. So, here's the rule: How do you know, if a quantity relates to power or amplitude? Check if squaring the quantity makes sense! If squaring makes sense, your quantity is likely to be an amplitude. If it does not make sense, you probably face a power-like quantity. For example, it does not make sense to square the power of a signal. But, it makes sense to square the amplitude of a signal, since this yields the power of the signal. Another indicator for when to use 10 or 20 is the following: If your quantity $X_{lin}$ follows from some computation that involves squaring some other quantity, use factor 10. In the following we calculate some examples of linear scale to dB scale conversions: Transform 100W into the dB scale. Reference $X_{ref}=1mW$.
Some examples¶
print ("X_dB = %.1fdB" % (10*np.log10(100/1e-3)))
We have to use factor 10, because we are clearly dealing with powers of a signal.
Transform 100V into the dB scale Reference $X_{ref}=1mV$.
print ("X_dB = %.1fdB" % (20*np.log10(100/1e-3)))
Here, we use factor 20, because we deal with voltage amplitudes of a signal.
Transform an air pressure of $5mPa$ into the dB scale. Reference $X_{ref}=20\mu Pa$.
print ("X_dB = %.1fdB" % (20*np.log10(5e-3/20e-6)))
This one is a bit more tricky. Is air pressure an amplitude or power? If you consider that an acoustic wave propagates through the air by a periodic change of the air pressure, it becomes apparent that pressure is an amplitude-like value. So, we use factor 20.
Transform the quantity $X_{lin}=\frac{E_b}{N_0}$ into the frequency domain, where $E_b$ is the average energy per bit and $N_0$ is the noise energy per bit.
Here, we have no values given, so we can only give an expression. First note, that this question is different from before, in the sense that here the reference level is explicitely given as the noise power. Second, we see we are working with powers here, so we have to use factor 10:
$$SNR_{dB}=10\log_{10}\left(\frac{E_b}{N_0}\right).$$This is clearly a sigal-to-noise ratio, since we relate signal power to noise power here. So, we can use the name SNR.
Even though choosing different factors for amplitudes and powers seems a bit strange, it is indeed quite elegant.
Let us now think of unit-less signals and let our reference values be always 1. Given a signal $x$ that at time $t$ has amplitude $x(t)$, hence its power at time $t$ is given by $P(t)=x^2(t)$. Now, let's convert both amplitude and power into the dB-scale:
$$\begin{align} x_{dB}(t) &= 20\log_{10}(x(t))\\ P_{dB}(t) &= 10\log_{10}(P(t))\\&=10\log_{10}(x^2(t))\\&=20\log_{10}(x(t))=x_{dB}(t) \end{align}$$In dB-scale the power and the amplitude of a signal have the same value! Hence, if somebody says "This signal is 10dB above that signal", there is no ambiguity wether she meant 10dB in amplitude or power.
The dB scale is a logarithmic, unitless scale. It always requires a reference quantity to be related against. The dB is calculated via two different expressions $$X_{dB}=10\log_{10}\left(\frac{X_{lin}}{X_{ref}}\right) \quad \text{or}\quad Y_{dB}=20\log_{10}\left(\frac{Y_{lin}}{Y_{ref}}\right).$$
- If you convert a quantity $X$ that relates to power or energy, the factor is 10.
- If you convert a quantity $Y$ that relates to amplitude, the factor is 20.
- If you convert an expression that contains squares, use factor 10.
- If you convert an expression that does not contain squares, use factor 20.
Do you have questions or comments? Let's dicuss below!