# Can sampling rate be a floating point number?

Suppose we have a sampling frequency for a signal of 15.5 samples/sec and we take samples for a period of 7 seconds. This means total samples are 108.5, does this make any sense?

Shouldn't the number of samples taken be an integer like 108 or 109? Or can the particular points in time from 0 second to 7 seconds on which to take the samples be determined in this case? How would one do that?

• What is the sampling rate if you take 217 samples over 14 seconds? – Harry Svensson Aug 12 '19 at 7:34
• yes, video, 29.97fps – user3528438 Aug 12 '19 at 7:55
• If your clock is one GHz, you get awfully close to 15.5/sec without using a float. So in seven seconds, you would have 108 samples (not 108.5). – WGroleau Aug 12 '19 at 21:08
• If a candy is \$1.50 and you get a 33% discount you will be expected to pay one dollar and four cents not one dollar and three point 8 cents. While there are systems that can output half a sample (CCD sensors for example) in general a sample exists or does not exist. So you get 108 samples but the sampling rate is still 15.5Hz – slebetman Aug 13 '19 at 7:38
• There's some comfusion about terms here. "Floating point" is a particular set of related representations of real numbers often used by computer. Typically programs use floating point values to model real numbers, so a more correct title might ask "Can sampling rate be fractional?", i.e. a non-integer real number. However, since the confusion in the title may have contributed to this becoming a HNQ, I'm hesitant to sugest the edit. – Vaelus Aug 13 '19 at 14:11

Forget sampling rate for a few seconds... Think about sampling period for a second, which is the time interval between two consecutive samples. This time can be an integer or any real number (as long as it’s positive, of course).

Sampling rate is simply the inverse of sampling period. Does it make more sense this way?

• “This time can be an integer” – actually it can't. There's no meaningful way in which a physical quantity could be integral, not even within a given unit system, because there's always a small uncertainly / jitter pertubation. – leftaroundabout Aug 13 '19 at 7:49
• @leftaroundabout there are models of physics in which physical quantities can be represented as integers, for instance, Newtonian mechanics, which models many quantities as real numbers, not probability distributions or wave functions. If you're arguing that we'll always be able to measure a small fractional part of any physical quantity, consider a servo system set to track to an integer value and which uses the best meter available for feedback. To the best of our measurements, it will settle on an integer value. – Vaelus Aug 13 '19 at 14:22
• And of course, the charge of a proton is +1 and an electron -1, no fractions, no uncertainty, no jitter. – MSalters Aug 13 '19 at 14:24
• @Vaelus it is specifically classical physics in which I consider it impossible to have integral time: in classical physics, every quantity does have an in principle exact real value, but we only ever measure / fix it to a finite-extend interval, and within such an interval almost all values (i.e., all that could actually occur) are irrational. – leftaroundabout Aug 13 '19 at 14:40
• @leftaroundabout - my choice of words was aimed at clarifying the basic question presented by the OP in the best way I could think of. I could have said “in the context of a first order model where the effects of jitter, relativity and quantum mechanics are neglected, we can define a scalar quantity called sampling period which can be assumed to be invariant and be expressed by any positive real number, which includes positive integers”. Maybe this would have been a more complete answer, but certainly not a better one. – joribama Aug 13 '19 at 21:22

Yes, the sampling rate can be any number you want.

But you obviously would not get partial samples in the end, you just have to round down.
In your example the first sample is taken at $$\ \frac{1}{15.5}s \$$ = 64.5 ms and then at every multiple from that. This means you get your last sample at 6,966 s. That is the 108's sample. So at 7 s you still have taken only 108 samples. And then at 7,0305 s you get the next sample.

You can imagine the samples beeing taken in a way like this dirac comb:

If you stop sampling between 3T and 4T you do not have partial samples. You just round down. T is the inverse of the sample frequency, or in your case 64.5 ms.

• FTR, the Dirac comb is not really how samples are taken in practice – that would be impossible to implement and, even even you only approximate it, usually a bad idea because of aliasing. For a real ADC the peaks are actually overlapping filter kernels. (But this does not invalidate your argument for the purposes of the question, in any way.) – leftaroundabout Aug 13 '19 at 7:59

Some things are always an integer. Samples are always integer. You can take 108 or 109 samples.

Sample rate can be a floating point number, or more generally a rational, or even a real.

You calculate the sample rate by dividing the number of samples (less one to get the number of periods between samples) by the time it takes to obtain those samples.

Generally a floating point number is an approximation to the real number you want. With double precision, it's a very good approximation, but it's usually inexact.

If you're given a sample rate, and a time, the product might be an exact integer, if the numbers are chosen carefully, but it probably won't be. It might be in error a small amount, due to the approximation of floating point representation. It might be in error a lot, because the source of your information chose very approximate numbers, or even made up the numbers to start with.

This means total samples are 108.5, does this make any sense?

Only in a limited sense. Since your sample interval of 7 seconds is not an integer multiple of the sampling period (1/15.5 Hz = 0.064516... s), it means that any arbitrary 7-second interval will contain either 108 samples or 109 samples, and the average across all possible 7-second intervals will be 108.5 samples.

If you take a series of contiguous 7-second intervals, you'll find that the sample counts alternate between 108 and 109, again resulting in an average of 108.5.