I have a real signal recorded 512Hz for 1s. After resampling the signal at 256Hz, I would like to compute its [spectral flatness][1]. To do so, I start by taking its discrete Fourier transform with `fft = scipy.fft.rfft(x)` and then I compute the power spectrum with `pw = np.abs(fft)`. When I compute the geometric mean of `pw` an error is raised because that the last coefficient of `fft` is equal to 0. I am trying to understand why.

This last coefficient returned by `fftpack.rfft` is defined as:
\begin{align*} \mathrm{Re}\big( y(n/2)\big) & = {} \mathrm{Re}\Big( \sum_{k=0}^{n-1} x_k e^{-jk\pi}\Big) \\[2mm]
 & = x_0 - x_1 + x_2 - x_3 + \ldots
where $(x_k)_{0 \leq k \leq n-1}$ is my resampled signal. A quick check that this quantity is close to 0 : `np.sum([x[k]*((-1.) ** (k % 2)) for k in range(x.size)])` gives me `5.68e-14`, which is not 0 but quite close. 

What does that say about my signal ? Usually the spectral flatness is defined without assuming that some coefficients in `pw` could be zero. So, am I doing something wrong (or not doing something I should do) ?

**Edit** : is there a convention which consists in saying that the flatness of the signal is 0 whenever a single "coefficient" returned by `rfft` is zero ?

  [1]: https://en.wikipedia.org/wiki/Spectral_flatness