Transoceanic Signal Transmission
Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
WebR - R in the Browser
WebR is a version of the statistical language R compiled for the browser and Node.js using WebAssembly, via Emscripten.
WebR makes it possible to run R code in the browser without the need for an R server to execute the code: the R interpreter runs directly on the user’s machine. Several R packages have also been ported for use with webR, and can be loaded in the usual way using the library()
function.
Analog vs Digital Transmission
In this notebook we will explore the potential advantages of digital transmission over analog transmission. We will consider the case of transmission over a long (e.g. transoceanic) cable in which several repeaters are used to compensate for the attenuation introduced by the transmission.
Remember that if each cable segment introduces an attenuation of \(1/G\), we can recover the original amplitude by boosting the signal with a repeater with gain \(G\). However, if the signal has accumulated additive noise, the noise will be amplified as well so that, after \(N\) repeaters, the noise will have been amplified \(N\) times:
\[ \hat{x}_N(t) = x(t) + NG\sigma(t) \]
If we use a digital signal, on the other hand, we can threshold the signal after each repeater and virtually eliminate the noise at each stage, so that even after several repeaters the trasmission is still noise-free.
Let’s start with the standard initial bookkeeping…
Now we can read in an audio file from disk; we can plot it and play it back. The readWave()
function returns the audio data and the playback rate, which we will need to pass to the playback functions.
The “Analog” and “Digital” Signals
We will now create two version of the audio signal, an “analog” version and a “digital” version. Obviously the analog version is just a simulation, since we’re using a digital computer; we will assume that, by using floating point values, we’re in fact close enough to infinite precision. In the digital version of the signal, on the other hand, the audio samples will only take integer values between -100 and +100 (i.e. we will use approximately 8 bits per audio sample).
Rememeber that there is no free lunch and quantization implies a loss of quality; this initial loss (that we can minimize by using more bits per sample) is the price to pay for digital transmission. We can plot the error and compute the Signal to Noise Ratio (SNR) of the quantized signal.
As expected, the error is between -0.5 and +0.5, since in the “analog” signal the values are real-valued, whereas in the “digital” version they can only take integer values. As for the SNR,
Can we hear the 17dB difference? A bit…
How to produce a quieter version of the audio clip
Transmission
Let’s now define a function that represents the net effect of transmitting audio over a cable segment terminated by a repeater: * the signal is attenuated * the signal is accumulates additive noise as it propagates through the cable * the signal is amplified to the original amplitude by the repeater
we can use the repeater for both analog and digital signals. Transmission of the analog signal is simply a sequence of repeaters:
For digital signals, however, we can rectify the signal after each repeater, because we know that values should only be integer-valued:
Let’s compare transmission schemes. As you can see, the SNR after digital transmission has not changed! Now the difference between audio clips should be easy to hear:
Note however that, if the noise amplitude exceeds a certain value, digital transmission degrades even less gracefully than analog transmission:
Understanding Digital Signal Degradation with Noise
The significant degradation in digital transmission when increasing NOISE_AMPLITUDE from 0.2 to 0.3 is a great example of what’s called the “cliff effect” in digital communications. Let me explain why this happens:
Why Digital Signals Degrade Suddenly
In the digital transmission system, we’re relying on the ability to correctly recover the original integer values by rounding after each repeater. This works well as long as the noise doesn’t push the signal across a decision threshold. Let’s analyze the critical threshold mathematically:
Each digital value has decision boundaries at ±0.5 from the integer value (e.g., for the value 42, correct recovery happens as long as the noisy signal is between 41.5 and 42.5)
In each repeater:
- Signal is attenuated:
x * ATTENUATION
(x * 0.5) - Noise is added: [-NOISE_AMPLITUDE, +NOISE_AMPLITUDE]
- Signal is amplified:
(x * ATTENUATION + noise) / ATTENUATION
- After simplifying:
x + noise/ATTENUATION
- Signal is attenuated:
The effective noise range after amplification becomes:
NOISE_AMPLITUDE * (1/ATTENUATION) = NOISE_AMPLITUDE * 2
Calculating the Critical Threshold
For reliable digital transmission, we need: NOISE_AMPLITUDE * (1/ATTENUATION) < 0.5
With ATTENUATION = 0.5: NOISE_AMPLITUDE * 2 < 0.5
NOISE_AMPLITUDE < 0.25
This explains why:
- At NOISE_AMPLITUDE = 0.2: The effective noise (0.4) is still below the critical threshold of 0.5
- At NOISE_AMPLITUDE = 0.3: The effective noise (0.6) exceeds the threshold, causing incorrect rounding decisions
Estimating the Upper Limit
Implement this in R to visualize the effect:
Why Digital Degrades Worse Than Analog Above Threshold
When noise exceeds the critical threshold in digital transmission:
- Each error causes a complete misclassification of the signal value
- These errors accumulate and cascade through multiple repeaters
- Once errors start occurring, the subsequent repeaters amplify these errors
In contrast, analog signals degrade gracefully - the noise accumulates linearly across repeaters but there are no sudden “jumps” between discrete values. This demonstrates the classic tradeoff in digital communications: excellent performance up to a critical threshold, followed by rapid degradation beyond that point.