Power Spectral Density from jTransforms DoubleFFT_1D

后端 未结 3 952
悲&欢浪女
悲&欢浪女 2020-12-08 22:36

I\'m using Jtransforms java library to perform analysis on a given dataset.

An example of the data is as follows:

980,988,1160,1080,928,1068,1156,11         


        
相关标签:
3条回答
  • 2020-12-08 23:13

    I think you need to interpret the output data as follows:

    10952       Re[0] = sum of all inputs = DC component
     -152       Re[5] - see note about a[1] being special - there is no Im[0]
       80.052   Re[1]
      379.936   Im[1]
     -307.691   Re[2]
       12.734   Im[2]
     -224.052   Re[3]
      427.607   Im[3]
      -48.308   Re[4]
       81.472   Im[4]
    

    The magnitudes are therefore:

    spectrum[0] = 10952
    spectrum[1] = sqrt(80.052^2 + 379.936^2) = 388.278
    spectrum[2] = sqrt(-307.691^2 + 12.734^2) = 307.427
    spectrum[3] = sqrt(-224.052^2 + 427.607^2) = 482.749
    spectrum[4] = sqrt(-48.308^2 + 81.472^2) = 94.717
    

    [Sorry about there being two separate answers from me now - I think two related questions got merged while I was working on the new answer]

    0 讨论(0)
  • 2020-12-08 23:14

    Each entry in the transform represent the (complex) magnitude of the frequency in the sample.

    the power density in a given frequency is just the magnitude of the complex amplitude of the transform in that frequency. the magnitude of a complex number is computed from its components and you should not have a problem obtaining this

    Each column represents amplitudes for increasing frequencies, starting from 0 (the first entry), then 2 Pi/T (where T is the length of your sample), until the last sample 2*Pi*N /T (where N is the number of samples)

    there are other conventions where the transform is returned for the -Pi * N /T frequency up to Pi * N / T, and the 0 frequency component is in the middle of the array

    hope this helps

    0 讨论(0)
  • 2020-12-08 23:15

    To get the magnitude of bin k you need to calculate sqrt(re * re + im * im), wheer re, im are the real and imaginary components in the FFT output for bin k.

    For your particular FFT re[k] = a[2*k] and im[k] = a[2*k+1]. Therefore to calculate the power spectrum:

    for k in 0 to N/2 - 1
      spectrum[k] = sqrt(sqr(a[2*k]) + sqr(a[2*k+1]))
    
    0 讨论(0)
提交回复
热议问题