# What is the Uncertainty or error due to sampling frequency?

If I want to detect the distance between two peaks in a signal sampled at 100 Hz. Then is it right to say that the first and second peaks occurred within 0.01 seconds of uncertainty? Therefore, the distance between peaks is 0.02 seconds uncertainty?

Then, based on that, how does the uncertainty propagates if I have a group of peaks and I want to find say the uncertainty in the mean and standard deviation of distance?

Does anyone have any idea what this uncertainty is called?

• Am I assuming that you know nothing about the bandwidth of the signal, i.e. you are not adhering to Nyquist-Shannon sampling theorem? – Marcus Müller Feb 8 at 18:44
• But if you're not restricting the bandwidth, how do you even know the peak appeared it it's not happened during a sampling instant? Are you making assumptions on the ADC architecture here? Or is your signal actually sufficiently band-limited for reconstructive sampling, in which none of the uncertainty you want to calculate exists in the absence of noise? – Marcus Müller Feb 8 at 18:47
• Yes, no, maybe. It depends on the nature of the signal you're measuring and the amount of noise. If the signal is low-noise and band-limited yet has a bandwidth that's a good fraction of the sampling rate, you may be able to infer peaks to an accuracy considerably greater than 10ms. If there's a lot of noise, and more so if the signal is very slow (i.e., daily variations), then the abyss is the limit as far as a lack of certainty goes. – TimWescott Feb 8 at 22:17

## 1 Answer

Uncertainty IS NOT determined by the sampling frequency (i.e., 100Hz) only. Uncertainty is mostly determined by both the Bandwidth of the signal you sampled (as stated by Marcus Muller) and the sampling frequency.

In fact, the uncertainty between sampled peaks can be solved by properly designed interpolation (or DAC) as long as the sampling theorem is met. The main reason is depicted as follows.

Although Nyquist-Shannon sampling theorem state that no theoretical reconstruction loss as long as the sampling frequency is twice larger than the bandwidth. But, YOU NEED TO RECONSTRUCT THE SAMPLED SIGNAL before the temporal analysis. Most of the analyzers forget to reconstruct (interpolate) their sampled signal while analyzing.

This sample code sample a simulated 2 Hz analog signal,x_a, (with sampling rate 1500 Hz) to a discrete-time signal,x_d, with 5 Hz sampling rate (nearly Nyquist rate) and then reconstruct this back,x_r.

%% This code simulate the AD/DA processing discussed in Chapter 4.8.3 [1]
close all; clear all;

%% parameters.
% analog
analog_fps = 1500;
analog_window_time = 3; %sec
t = 0:1/analog_fps: analog_window_time-1/analog_fps;

% digital
digital_fps = 5;
n = downsample(t,analog_fps/digital_fps);

% ADC: Quantizer
X_m = 1; % Range
B = 10;% Bit number.

%% Signal generation
freq_hz = 1; % Hz.
x_a_1 = 0.5*cos(2*pi*freq_hz*t+0.1);

% add a small high-frequency component as asked.
signal_freq = 2; %Hz
x_a_2 = 0.5*cos(2*pi*signal_freq*t+pi/2);
x_a = x_a_1 + x_a_2;

%% ADC
% Sampling
x_s = downsample(x_a,analog_fps/digital_fps);

% Quantizing (abs of input value should not over 1)
% x_d = Quantizing(x_s,B,X_m);  % A For complete ADC, a quantizing should
% be added here.
x_d = x_s; % For basic case, we skip the quantizing here.

%% DAC
% up sample / DAC
x_up = upsample(x_d,analog_fps/digital_fps);

% LPF (Reconstruction Filters)
h = intfilt(analog_fps/digital_fps,4,0.9);
%% Important
% please not the parameter 0.9, ideally should be 1 for Nyquist rate.
% 0.9 here is the ratio of Nyquist.
% Given known limit band signal, a shorter ratio can enhance SNR by oversampling.
%  (i,e, here I filterout the freq larger than 2.5(Nyquist rate) * 0.9 = 2.25Hz)

x_r = filter(h,1,x_up);
x_r(1:floor(mean(grpdelay(h)))) = [];
x_r = [x_r zeros(1,floor(mean(grpdelay(h))))];

%% Display

figure;
plot(t,x_a);
hold on;
plot(n,x_d);
plot(t,x_r);
title('analog signal (1500Hz) v.s. digital signal (5Hz) v.s. Reconstructed signal (1500Hz)');
legend('x_a','x_d','x_r');


If you forget to interpolate, the uncertainty of x_d is very high!! However, as long as you properly interpolate the x_d, you will obtain the x_r where the uncertainty is much much smaller.

To sum up, as long as the band-limited signal is sampled higher than the Nyquist frequency, properly reconstruction (interpolation) can theoretically reduce the uncertainty to a very small amount (which depends on the interpolation filters you designed). The interpolation filter sample I provided above is FIR and zeros phase filter, which means finite impulse response (i.e., no error propogation and phase distortion).

DO NOT FORGET to RECONSTRUCT YOUR SIGNAL, or you will overestimate the uncertainty.