0
$\begingroup$

I have been working with digital signals for quite some time and this fencepost-error issue when taking a simple example of sample frequency and sample spacing always trips me up (and I must say drives me completely crazy):

$f_s$: sampling frequency, number of samples per second

$t_s$: sampling spacing, $1/f_s$

This is all very neat. The time points of a 4 Hz signal collected over 1 second:

[0, 0.25, 0.5, 0.75]

This is 4 samples, with sample spacing 0.25, lasting.... 3*0.25 = 0.75 s!

Okay, lets try 0.25*4 = 1 s

[0, 0.25, 0.5, 0.75, 1]

now we have 5 samples!

All these problems go away if we take the first sample at 0 as known and fixed, then sample from there, and this is a clear example of fencepost error. But this is an issue I always get confused about and can never find much discussion or references on, so would like the conventions explained to me here so I can refer back in future and save me a headache :)

Thanks, Joe

$\endgroup$
1
  • 2
    $\begingroup$ I think this answers your question. $\endgroup$
    – Jdip
    Jan 16, 2023 at 12:49

2 Answers 2

2
$\begingroup$

This is the way I look at it; the duration of a discrete-time signal is $N/f_s$. In your first example, with four samples, the duration is one second.

Perhaps one intuitive way to see this is to consider one sample as "capturing" the value of the signal in a time interval, from $t_s/2$ seconds to the left of the sample, to $t_s/2$ to the right of the sample. Then, the sample at $t=0$ represents the signal from $-0.125$ to $0.125$ seconds, and the sample at $t=0.75$ represents the signal from $0.625$ to $0.875$, for a total duration of $0.875+0.125$, or one second.

Another approach: say you have a continuous-time signal that lasts exactly one second (leaving aside for a moment the fact that in general this signal can't be sampled without aliasing). You want to sample it with $t_s=0.25$. You need one sample at $t=0$ and one sample at $t=1$, for a total of five samples. This is consistent with the duration of the discrete-time signal, which is 1.25 seconds.

Yet another: say you sample a signal with period 1 second at rate $f_s=4$ for a long time, and want to group the samples so that each group covers one period. You would group the samples as:

0, 0.25, 0.5, 0.75

1, 1.25, 1.5, 1.75

...

or four samples per period, so four samples "cover" or "represent" one period of one second.

$\endgroup$
0
$\begingroup$

Thanks for the great answer, thats very helpful. I've put some further thoughts below.

Equivilently, you can image the samples as covering [0.125, 0.375, 0.625, 0.875] (i.e. middle of the range [0 - 25, 0.25 - 0.5, 0.5 - 0.75, 0.75 - 1]).

This is similar to classic fencepost issue e.g. counting from 1 to 5. We say [1, 2, 3, 4, 5] we count 1-2, 2-3, 3-4, 4-5, 5-6!? This demonstrates that when we count what we are actually doing is counting one side of a range. We can count the 'right-side' (0-1, 1-2, 2-3, 3-4, 4-5) or equivilently the left side (1-2, 2-3, 3-4, 4-5, 5-6).

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.