来自jTransforms DoubleFFT_1D的功率谱密度 [英] Power Spectral Density from jTransforms DoubleFFT_1D

查看:322
本文介绍了来自jTransforms DoubleFFT_1D的功率谱密度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jtransforms Java库对给定的数据集进行分析.

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

数据示例如下:

980,988,1160,1080,928,1068,1156,1152,1176,1264

我正在jTransforms中使用DoubleFFT_1D函数. 数据输出如下:

I'm using the DoubleFFT_1D function in jTransforms. The data output is as follows:

10952, -152, 80.052, 379.936, -307.691, 12.734, -224.052, 427.607, -48.308, 81.472

我在解释输出时遇到问题.我知道输出数组中的第一个元素是10个输入的总和(10952).是

I'm having trouble interpreting the output. I understand that the first element in the output array is the total of the 10 inputs (10952). It's

我不理解的输出数组的其他元素.最终,我想在图表上绘制输入数据的功率谱密度,并找到介于0和.5 Hz之间的量.

the other elements of the output array that i don't understand. Ultimately, I want to plot the Power Spectral Density of the input data on a graph and find amounts between 0 and .5 Hz.

jTransform函数的文档说明了状态(其中a是数据集):

The documentation for the jTransform functions states (where a is the data set):

public void realForward(double[] a)计算实数的一维正向DFT 数据将结果保留在中.输出数据的物理布局 如下:

public void realForward(double[] a) computes 1D forward DFT of real data leaving the result in a . The physical layout of the output data is as follows:

如果n为偶数

a[2*k] = Re[k], 0 <= k < n / 2
a[2*k+1] = Im[k], 0 < k < n / 2
a[1] = Re[n/2]

如果n为奇数,则

a[2*k] = Re[k], 0 <= k < (n+1)/2
a[2*k+1] = Im[k], 0 < k< (n-1)/2
a[1] = Im[(n-1)/2]

此方法仅计算实际转换的元素的一半. 另一半满足对称条件.如果你想要完整的 真正的正向变换,请使用realForwardFull.要获取原始数据, 在此方法的输出上使用realInverse.

This method computes only half of the elements of the real transform. The other half satisfies the symmetry condition. If you want the full real forward transform, use realForwardFull. To get back the original data, use realInverse on the output of this method.

参数:a-要转换的数据

Parameters: a - data to transform

现在使用上述方法:(由于我的数据数组的长度为10,因此使用"n是偶数"方法)

Now using the methods above: (since the length of my data array is 10, the "n is even" methods are used)

Re[0] = 10952
Re[1] = 80.052
Re[2] = -307.691
Re[3] = -224.052
Re[4] = -48.308
Re[5] = 12.734

Im[0] = -152
Im[1] = 379.936
Im[2] = 12.734
Im[3] = 427.607
Im[4] = 81.472

一些问题: 这个输出看起来正确吗?在我看来,Re [0]不应为10952,这是原始数组中所有元素的总和.

So some questions: Does this output look correct? It seems to me that Re[0] should not be 10952 which is the sum of all elements in the original array.

似乎应该稍微纠正输出:(我错了吗?)

Seems like the output should be slightly corrected: (am I wrong?)

Re[0] = 80.052
Re[1] = -307.691
Re[2] = -224.052
Re[3] = -48.308
Re[4] = -152

Im[0] = 379.936
Im[1] = 12.734
Im[2] = 427.607
Im[3] = 81.472

现在使用以下方法发布在论坛上:

Now using the following method posted in the forum:

要获得bin k的大小,您需要计算sqrt(re * re + im * im),其中re,im是bin k的FFT输出中的实部和虚部.

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

对于您的特定FFT re[k] = a[2*k] and im[k] = a[2*k+1].因此要计算功率谱:

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]))
}

因此:

spectrum[0] = 388.278
spectrum[1] = 307.955
spectrum[2] = 482.75
spectrum[3] = 94.717

一些问题.这个数据看起来正确吗?我在正确的轨道上吗? 然后,该频谱数据会绘制出如下内容吗?

Some questions. Does this data look correct? Am I on the right track? Would this spectrum data then plot out something like this:

388.278 at .125 Hz
307.955 at .25 Hz
482.75 at .375 Hz
94.717 at .5 Hz

我要离开吗?我的目标是制作一个从0到.5Hz的功率谱密度条形图.

Am I way off? My goal is to produce a Power Spectral Density bar chart from 0 to .5Hz

推荐答案

我认为您需要按以下方式解释输出数据:

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]

因此,幅度为:

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]

这篇关于来自jTransforms DoubleFFT_1D的功率谱密度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆