# How to set sampling frequency of an acceleration data set

I have a set of accelerometer readings in $X, Y, Z$ axes obtained from an android based smart-phone. The data in $(X, Y, Z)$ was recorded at different time stamps and there is no uniform time period for recording the data.

My data set looks as timestamp $X, Y, Z$. First, I did a filtering (using a low-pass) on this data and now want to perform $\textrm{FFT}$ on a timewindow of 1 min or may be a window containing 250 samples (not very sure about the window length). I am using this FastFourierTransform class of apache commons in Java.

I am getting $\textrm{FFT}$ magnitude but I was wondering how do I know the corresponding frequency of each $\textrm{FFT}$ mag. I know corresponding frequency would be $(n\cdot F_s)/N$ where $n$ is the bin number or data point index, $F_s$ is sampling frequency and $N$ is number of input data points over the window. Now my question is how do I know $F_s$ for a given set of data say for example input data in an array as $\begin{bmatrix}1&2&3&4&5&6& 7\end{bmatrix}$ over a window of size $N_t$ millisec where $N_t=(\textrm{lastTimeStamp}-\textrm{firstTimeStamp})$

Is it $\displaystyle \frac{7}{(N_t\cdot 10^{-2})} \textrm{Hz}$?

This also immediately follows by doing so if this agrees with nyquist sampling frequency? and this says $F_s\ge2F_{max}$ in the signal and I don't know the maximum frequency over the time window $N_t$.

• When you mentioned time stamps you mean that for each sample you have the time? If the sampling time is not regular (the sampling time happens with different periods) you can not just do Filtering and FFT - first you need to create a "fixed sampling series" and then run the process. When you create this series you actually specify the sampling frequency. If you are not emulating a data stream with Fixed Sampling Period I would say that your results are meaningless. – Moti May 23 '15 at 4:16

## 1 Answer

If you don't have a uniform time period (or nearly so) between samples, then you don't have a sample rate, and the FFT result may well be garbage.

If you don't know ahead of the sampling the Nyquist frequency for the signal, then the sampling might be already contaminated by aliasing.

If the samples are close enough together relative to the highest frequency in the signal's spectrum, then you may be able to interpolate a new set of evenly spaced samples, which will then have a known sample rate (based on the distance of the new even spacing).

• if I understand correctly, I need to resample my data set since the timestamps are not equally spaced. How do I set my sampling frequency then? I know the sampling frequency should be > twice the maximum frequency present in the signal. But since this is discretized data set at different timestamps, how do I know the max freq?Do I consider the max freq of our movement and vibration as well while resampling? Literature says, during our body movement the avg frequency 15 Hz and vibration in vehicles 3-5 Hz. So, if I set my sampling frequency as 50 Hz (> [(15+5)*2]), will that be reasonable? – user26161 May 24 '15 at 5:32