# How Do I Measure the Time Duration of a Finite Length Discrete Sequence?

Assume I have a five-sample time-domain sequence (none of the five samples are zero valued) and the time period between each pair of samples is one second. Measured in seconds, what is the time duration of my five-sample sequence?

• can you please change your title to actually describe the problem instead of your (obviously wrong, otherwise you'd have answered it yourself!) assessment of its difficulty? Nov 1, 2020 at 21:17
• (and I don't ask that to annoy you, I think it's actually critical to be careful about the wording in how you state the problem) Nov 1, 2020 at 21:18
• If one second elapses in one second, then how long does it take for five seconds to elapse? Hint: it is a perfectly linear relationship...I don't know how to help, but something is wrong here Nov 1, 2020 at 22:39
• @Laurant Duval. I have two ideas. Conjecture# 1: Subtracting the time instant of the first sample from the time instance of the fifth sample implies that the duration of my five-sample sequence is four seconds. Conjecture# 2: The notion that the frequency sample spacing of the DFT of my sequence is equal one over the my sequence's time duration implies that the duration of my five-sample sequence is five seconds. One of those conjectures is incorrect. I was hoping one of you experts here would help me. Is anyone on this web site willing to help me? Nov 1, 2020 at 22:46
• The question is not "what is the time duration of an N-sample sequence?", but "what is the most useful definition of the time-duration of a sequence?". Take whatever definition you like and be clear about it. Nov 2, 2020 at 7:52

The following graphic should clear up why a useful answer is 5 seconds, consistent with conversions between the discrete-time and continuous-time domains. A good example of this are discrete time approximations to continuous time integration or differentiation where the inclusion of $$\Delta T$$ (sample period) is made. With all such approximations, the time duration attributed to each sample is one sample interval. For the Forward Euler approximation specifically, each sample covers the time duration up to and not including the next sample. Such as in the first graphic the time duration for a sample at $$t=0$$ is one sample interval of one second; up to and not including the next sample at $$t=1$$ when sampled at one sample per second, with a total time duration for the one sample as one second.

The bottom figure then shows how this would apply to five samples starting at $$t=0$$ resulting in a total time duration of 5 seconds.

The plot below shows the Forward Euler discrete-time approximation for the integration of a continuous time waveform $$x(t)$$, which would be given as follows in the formula below and demonstrated in the graphic, best showing how each sample carries the time duration of the sample period (and as David has pointed out in the comments, this equally represents the zero-order hold approach in the output of a typical Digital to Analog converter):

$$\int_0^{NT}x(t)dt \approx \sum_{n=0}^{N-1}x[n]T$$

The actual range of time used for each sample is specific to the analog-digital translation approach used, but would cover one sample duration in all cases, leading to a total duration of 5 seconds for the OP's case.

• Your integration graphic is VERY interesting! Thank you. Nov 2, 2020 at 12:42
• This is also consistent with the sample and hold approach in ADCs. Nov 2, 2020 at 18:02

By the way, "measure" isn't quite the right term here: you're not measuring a physical quantity, but that would be nitpicking; a sequence doesn't have duration. (You have another question that also touches upon that, and I always found it helpful to remind myself that a sequence like 0.1, 0.3, -0.2, 0.0, 1.0 has no duration, as it's just a bunch of numbers in order. Duration is an attribute we infer from it representing something, which usually doesn't matter for the math we do on the sequence.)

The continuous-time signal it represents has a duration! So, let's look at that.

So, first of all, we need to make an assumption: your signal is bandwidth-limited – otherwise sampling it had made no sense.

Then: we need to assume that it's periodically repeating! Otherwise, you don't get to claim that your DFT is representative of your continuous signal's spectrum (only periodic signals have line spectra).

And then you're right, your signal repeats every 5 sample periods.

If we take away the assumption that the underlying time-continuous signal is periodic, we end up in a hard situation: We have a signal that is strictly bandlimited, so it can't be finite in duration!

A good reminder of that is the reconstruction theorem, where we interpolate all the samples we have with sinc. The nice thing about that is that each sinc is zero at all but one sample instant (where it takes the value of the sample).
The less nice thing about that is that a sinc never truly stays zero. (Look at Dan Boschen's integral figure and replace the rectangles with sincs centered at each sample instant. When do the sincs disappear? Never!)

And thus I think, the real answer (applying Occam's razor of using as few assumptions as necessary) is that

• you have no signal duration without interpreting your sequence as representation of something else
• if you do that interpretation of the sequence as samples from a bandlimited signal, then the signal that effected these samples is infinite in duration,
• if you do that interpretation of the sequence as samples from a bandlimited, periodic signal, then only periods of five sample instants make sense. (and it's still infinite)

So, in any case, if we assign an attribute "length" to this sequence, strictly speaking, it'd be infinite.

• I thank all of you guys for your thoughts regarding my "not so simple after all" question. Nov 2, 2020 at 12:44
• @knight If you seek a deeper perspective on the DFT, I can recommend these -- two posts. Good luck. Nov 2, 2020 at 12:48
• @OverLordGoldDragon you must have misread my answer: I don't claim the DFT assumes anything. The DFT doesn't care about the continuous signal at all, it's just a bijective finite-dimensional vector space base transform. What cares is the interpretation as spectrum, and as said, that only works if you assume the underlying signal to be periodic. Otherwise, the IDFT of that shaped with sincs don't combine to the same signal as was sampled (which is what these two posts are about :) ) Nov 2, 2020 at 14:02
• Whoever claimed that the DFT is representative of the signal's spectrum? The OP has not mentioned the DFT (at least not in the versions of the question that I have seen; I haven't checked the edit history). Nov 2, 2020 at 17:33
• @DilipSarwate knight's DFT comment: dsp.stackexchange.com/questions/71181/… Nov 2, 2020 at 17:46

The OP's query and his response to Laurent Duval's comment is very reasonable and the OP's question should not be closed. See the answer by Richard Lyons (author of the well-regarded book Understanding Digital Signal Processing) to this question. Richard now concludes that the OP's second choice (that the signal duration of a 5-sample discrete-time signal with one sample per second is 5 seconds) is correct, and that the notion that the first and last samples are separated by only 4 seconds and hence the signal duration is 4 seconds is not appropriate.

• What's the time between two (second) tics of a clock ? 1 second or two seconds? If you consider each sampling process as a tic then the time-between 5 tics is 4 seconds. But if you ask how many seconds 5 tics make?, most typically you mean 5 seconds ;-)) Nov 1, 2020 at 23:42
• A very radical question indeed, with ontological subtleties Nov 2, 2020 at 7:16
• Indeed. I disagree – the sequence strictly speaking has no duration (has a number of elements, OK, but that's not a duration). The thing that has a duration is the cont.-time signal it represents, but when you think of reconstruction, the signal generated by these five samples, namely the sum of five shifted, weighted sincs, then that signal's support is far from five sample periods; it's infinite. Nov 2, 2020 at 8:08
• @Fat32 well, I think your questiony-comment was pretty on point, and only OP can answer it: whether they meant "the duration of signal that influenced these five samples", "the time for which these five samples are 'valid'", or "the time between these five sample instants" yield three different answers :) Nov 2, 2020 at 11:21
• /me hides in a hole Nov 2, 2020 at 11:34

I hope this is clear and helpful.

Given a continuous-time signal $$x_a(t)$$, if you perform an ideal impulse-train modulation based uniform sampling of it by a sampling period of $$T_s$$ seconds as indicated by:

$$x[n] = x_a(t_n) = x_a(n T_s)$$

and obtain $$N$$ such samples, then the duration of your observation is given by :

$$\Delta T = (N-1)\cdot T_s$$

The time-stamp of the first sample $$x[0]$$ will be at $$t_0 = 0\cdot T_s =0$$ and the time-stamp of the last sample $$x[N-1]$$will be at $$t_{N-1} = (N-1)\cdot T_s$$.

Nevertheless, in some applications (such as sample rate conversion) it's customary to call the duration as $$\Delta T = N \cdot T_s$$, by adding one more period $$T_s$$ that spans after the last taken sample $$x[N-1]$$ and the next un-taken sample at time $$t_N = N \cdot T_s$$.

• The issue with taking the time duration as $(N-1)T_s$ is that the concatenation of sequences of $N$ samples (and so, duration $(N-1)T_s$) and $M$ samples (duration $(M-1)T_s$) has duration $$(N+M-1)T_s \neq (N-1)T_s + (M-1)T_s,$$ that is, the durations don't add as one should expect. This difficulty does not arise if the duration is defined as # if samples times sampling interval. Nov 1, 2020 at 23:43
• @DilipSarwate Yes but the one who is making the concatanation should be aware enough of the fact that boundary samples are not touching ;i.e, There's one period gap between each boundary sample of the concatanated blocks, and the very last sample period should also be discluded... Nov 1, 2020 at 23:46
• The key question here is: what does the continous signal do before and after the taken samples. We know that $x(nT) = 0$ if n is an integer and not $[0,1,2,3,4]$. However that does NOT mean that $x(t), t<0$ or $x(t)=0,t>4$. Quite the opposite, if x(t) is bandlimited it's non zero everywhere EXCEPT $t=nT$ Nov 2, 2020 at 15:22
• @Hilmar such a tricky problem ! Nov 2, 2020 at 16:13

I throw another on in the mix:

The question is oddly worded but my interpretation is "I have a 5 point discrete sequence sampled at $$1Hz$$, what's the length of the corresponding continuous time domain signal in seconds".

First we need to define what we mean by "corresponding". In order for the sequence to completely capture a continuous signal, this signal must be bandlimited. So if we require our sequence to represent a complete description of the corresponding continuous signal, the length of that signal must be infinite. (Since all band limited signals have inifinite lengths)

If we allow for aliasing, then the length is "whatever you want it to be". There is an inifite number of continuous signals that would result in our original sequence when sampled. In other words, for any given time length you can construct a continuous signal that will sample as our original sequence.

EDIT:

So it seems like I misinterpreted the question. OP wants to know ""what is the time duration of my five-sample sequence?"

The answer to this is: it doesn't have any. The length is $$5$$ (no units) and that's that.

In order to define time length as a physcial quantity you need to create a physical manifestation of that discrete sequence. In other words, you need to run it through a D/A converter and then you can measure actual physical time. The result of this measurement will be dependent on the implementationd details of the D/A. D/A create compromise between "time smearing" and "aliasing" An "ideal" D/A converter would create a signal that's infinitely long, but of course, that's impossible and impractical.

We are having some fun philosphical discussion on this topic with fairly different opinions. Now that would be all futile, if you could simply measure it, but it turns out there is no well defined "time length" that's measurable and would provide the definitive answer.

• My question did NOT ask "what's the length of the corresponding continuous time domain signal in seconds? My question asked "what is the time duration of my five-sample sequence?" Nov 2, 2020 at 18:24
• @knight Mind that the dots themselves have no "duration", they're data - so any talk of duration is really asking "what duration do these samples represent?", and answer will vary depending on what exactly you seek. Nov 2, 2020 at 18:33
• @Hilmar- Even with aliasing, how does that change the time duration? It would still be 5 seconds of the underlying waveform regardless, would it not? Nov 2, 2020 at 18:49
• (specific to the duration we use for the samples we select from the infinitely long, if bandlimited, waveform) Nov 2, 2020 at 21:21
• @Fat32 that makes the most sense to me Nov 3, 2020 at 1:34

I would answer $$4+\epsilon$$ seconds. Because Richard Hamming, one of my (our?) godfather is credited with this "The purpose of computing is insight, not numbers". As commented by many, precise definitions and usefulness are necessary.

Before explanations, let me play on terms, and propose a first (silly?) answer. Thus, my first answer is:

$$\frac{1}{24}\; \textrm{second}^4\,.$$

Yes, in seconds to the fourth power. Indeed, if the time period between each pair of samples is one second, the simplest geometrical structure allowing five points to be equidistant is the pentatope, or Four-Simplex. This is the simplest polytope in a four-dimensional space. In 1D, two points can be separated by one second. For three points, one needs to place a equilateral triangle in the plane. With four points, a tetrahedron, and so on. The hypervolume of a pentatope with vertices $$(0,0,0,0)$$ ,$$(a,0,0,0)$$ ,$$(0,b,0,0)$$ ,$$(0,0,c,0)$$ ,$$(0,0,0,d)$$ is $$\frac{abcd}{24}$$, see Hypervolume of the 4-simplex. This would suppose that we live in a time-space with at least four time dimensions, a bit too much for the stability of the laws of the Universe. This was meant to emphasize on how far people could go on things as "natural" as each pair.

Going back to 1D. The question is about a "five-sample time-domain sequence". To me, not a signal per se, while it might represent some signal, continuous or discrete, whose acquisition method is not specified (yet). The mention of time in second can be misleading, only providing a unit to the $$x$$-axis. Let us rely on the notions of support from mathematics. As you can see, people tried to define unambiguous definitions, and there are many. As a pure sequence, the set-theoretic support of the sequence is finite. The closed support (intersection of all closed sets that contain the set-theoretic support) and compact support would be the same interval $$[0,4]$$ in seconds. Its essential support would be of length $$0$$.

For signal processing, I understand the idea that each sample is related to some interval of one second (hence the 5-second length answer). And I voted for Dilip Sarwate's answer, which means that this question is still triggering my mind. However, after a second thought, I have no idea about the way the original signal was sampled: maybe the last sample was averaged over 2 seconds, while the first one had "instantaneous capture". The fact that "The time period between [consecutive] samples is one second" may be a choice of storage, an artifact, a result for compresive sensing, etc.

In other words, I don't know if some hypothetical signal was regularly sampled. So with minimal hypotheses, another side of the Ockham razor evoked elsewhere, I would consider that if it was indeed sampled in the real world, it can be imperfect, because of integration time, or jitter, and I'd allow some uncertainty $$\epsilon \ge 0$$. Hence, my present answer is:

$$4+\epsilon\,.$$

on my most solid grounds. At least, something to discuss openly.

• Laurent you finally turned the problem into a Sunday Puzzle ! ;-) You know such a problem makes absolutely no sense without clearly stating which sampling method was used to obtain those samples. And if it's not made explicit, then it's almost a law to assume single channel uniform sampling.. ;-) The problem is about the last sample. Whether it's timing is included or not. My answer clearly describes what happens if you include or disclude the last sample interval. But nobody can give an answer to which one to accept as the definition, as there's no correct answer to that question. Nov 2, 2020 at 22:51
• Mmmh, are you sure that the problem is NOT about the first sample? ;-) Nov 2, 2020 at 22:54
• :-)! Yes the first one can also be cause of the discrepancy ! Nov 2, 2020 at 22:56

I've pondered a better take on this; "what is the duration?" can ask two separate questions:

1. For how long have we been sampling?
2. How much time's worth of information is contained in our signal?

I'd argue the answers to these are, unambiguously, $$(N - 1)/f_s$$ and $$N/f_s$$, respectively. To interpret either, I'll refer to following sampling times: $$t=[0, .1, .2, .3, .4, .5, .6, .7, .8, .9] \text{sec}$$.

1. For how long have we been sampling?

We begin with first sample. At that time, no time has passed, else we wouldn't be "at that time" but at later time, so we've been sampling for a total of 0 sec. At next sample, 0.1 sec have passed since we began sampling - so we've been sampling for 0.1 sec. And so on: total duration = 0.9 sec.

2. How much time's worth of information is contained in the signal?

The answer to this is either 0 sec or 1 sec. Refer to other answers, but basically there's agreement that the sequence is representative of physical source process in one of below senses:

Black arrows are values of observations we draw from a system (purple), and blue lines (white gaps for clarity) are time intervals spanned by observations.

Which is "better", A or B? Well, with B, we're saying the observation at $$t=.1$$ "speaks for" the process for $$t=[.1, .2)$$, where with A we're saying it represents $$t=[.05, .15)$$.

• Note for $$t=.3$$, B fares better, since values within $$[.3, .4)$$ are much closer on average to value at $$t=.3$$, than values within $$[.25, .45)$$. If we shifted the whole process left by $$.05 \text{sec}$$, A fares better. Point is, we just defined "better" as "more representative", which we measured as "less variance".
• B is more akin to "speaking for the future" than A is, and "reverse B" where blue line is drawn all the way left is guilty of "speaking for past". In this sense, A is the optimal scheme in localizing observations.

Example 1: take an "instant thermometer" and sample a lake's temperature every 30 minutes, 6 times.

• For how long have we been sampling? We started at 6AM, finished at 8:30AM --> 2.5 hours.
• How much time's worth of information is contained in our data? If noone's unloading lava nearby, temperature will change slowly over time, so every sample is representative of 30 minutes --> 3 hours.

Example 2: suppose we count the number of people at a restaurant once a day at the same hour, 6 times.

• Sampling duration: 5 days.

• Do we have 6 days' worth of "number of people present in restaurant" information? Hardly; the number of people can vary wildly depending on time of day and day of week. Large variance. Instead, we can say that each of our observations reasonably captures the number of people over 1 hour span - giving us 6 hours' worth data (non-contiguous).

So more generally, we can say that "duration" of a sequence in terms of information contained is $$N\cdot \Delta t_e$$, where $$\Delta t_e =$$ "effective time represented by each sample". It can be less than, or equal to, but not greater than $$f_s^{-1}$$, as that'd imply that a sample at $$t=0.1$$ "speaks for" a sample at $$t=0.2$$ more than that sample itself. So $$f_s^{-1}$$ is maximum represented duration.

Whatever the case, we associate a "representative time" to each individual observation, ultimately doing $$\cdot N$$ rather than $$\cdot (N - 1)$$.

... or not. We may have a scenario where it makes more sense to say samples represent only what's between them - in which case we're back to $$(N-1)$$. The point of this answer is more to illustrate what "depends on definition" can mean (but still that $$\cdot N$$ makes more sense for most purposes) - which hopefully is conveyed.

• that little notch between the ".2" and ".3" samples is indicative of an inadequately-sampled function. Nov 22, 2020 at 20:19
• @robertbristow-johnson Indeed; point was illustrating the "observation as representative of time" idea. I went with detail here in what I insufficiently described in my first answer, namely with articulating "duration of observation" vs "represented duration". Nov 22, 2020 at 20:25

### Discrete Fourier Transform says it's A!

I derived the closed form solution for DFT of a sine, which says that the correct continuous-time expression for

$$x[n] = \cos(2\pi f_0 \mathbf{t}[n]), \\ \mathbf{t} = [0, 1, ..., N - 1] \cdot s,\ s = \text{sampling period}$$

is

$$x(t) = \Pi\left(\frac{t - (T - s)/2}{T}\right) \cos(2\pi f_0 t)$$

where $$T = Ns$$ is the duration, and

$$\Pi(t) = \begin{cases} 1,\ -1/2 \leq t \leq 1/2 \\ 0,\ \text{otherwise} \end{cases}$$

is a rectangular window, which in this case is

$$\Pi\left(\frac{t - (T - s)/2}{T}\right) \begin{cases} 1,\ -s/2 \leq t \leq T - s/2 \\ 0,\ \text{otherwise} \end{cases}$$

It spans half a sampling interval to left of first sample, and half to right of last sample!

This concurs with my other answer. It is, however, not an absolute - other definitions can be more useful depending on context. But if we're interested in how the DFT "sees" the sampling of a continuous function, this is it.

It's $$N/f_s$$. Because consider what happens if it's $$(N-1)/f_s$$ instead; take a sequence $$x$$ of 6 samples, sampling once per second. Going by latter, defining "duration" as that between samples, we get

Now what is half the "duration" of $$x$$? Well, take half the sequence and measure the same:

Bad. If on the other hand we define duration as intervals midpointed by samples:

Good to go. This definition is also better grounded physically; suppose we wish to integrate. Doing so, we'd draw Riemann shapes (e.g. rectangles) in the discrete case, but regardless of shape, we'd have $$N$$ bins, so if finding e.g. average velocity, the physical interval spanned by integration would be $$N/f_s$$.

To be clear, this is largely a matter of definition, as a case can be made the other way; above's meant to show ways in which $$N/f_s$$ is more sensible.

• I don’t completely follow your logic that taking midpoints allows you to then take half the samples? (What do you get with 5 samples)? But agree that it is a matter of definition of how we want to relate continuous time to discrete time and what we may already know about the physical process (causal? Etc) Nov 2, 2020 at 13:31
• Why do you have 5 samples in the first example and 6 samples in the second? How would mid-points work with 5 samples? I also don't really see why halving the sequence length is more sensible. Why 1/2 why not 1/3, 1/4, 1/10 etc? Nov 2, 2020 at 14:38
• @DanBoschen Arguably neither definition handles half of an odd sequence unless we loosen up "half" a bit and permit drawing half a sample with half the duration; then midpoint permits half the blue line, while "between" still insists on an integral number, so $N/f_s$ still wins. But at least in one of two cases (even) $N/f_s$ clearly wins, also in integration sense. Nov 2, 2020 at 18:20
• @David 6 samples both cases, and see previous comment. On 1/3, 1/4, we'd just need more samples, I used a minimal example. The stronger case overall is integration Nov 2, 2020 at 18:22
• //"If on the other hand we define duration as intervals midpointed by samples..."// --------- i haven't always been on board with Over's answers, but this is the correct way of looking at it. Dan's answer is correct in the length, but it's more correct to center the precise frequencies of the DFT bin in the center of the adjacent and contiguous frequency bands that span from -Nyquist to +Nyquist. if $N$ is even, you have to split the $\frac{N}2$ bin in half. Nov 22, 2020 at 20:16