Wolfram mathematica 使用Mathematica?对离散数据进行连续傅里叶变换?

Wolfram mathematica 使用Mathematica?对离散数据进行连续傅里叶变换?,wolfram-mathematica,fft,Wolfram Mathematica,Fft,我有一些周期性数据,但数据量不是 这个时期。如何分析这些数据?例如: %让我们为测试创建一些数据: data = Table[N[753+919*Sin[x/623-125]], {x,1,25000}] %我现在收到了这些数据,但不知道它来自 上面的公式。我正试图从“数据”中重建公式 %看看傅里叶级数的前几个非常数项: ListPlot[Table[Abs[Fourier[data]][[x]], {x,2,20}], PlotJoined->True, PlotRange-&g

我有一些周期性数据,但数据量不是 这个时期。如何分析这些数据?例如:

%让我们为测试创建一些数据:

data = Table[N[753+919*Sin[x/623-125]], {x,1,25000}] 
%我现在收到了这些数据,但不知道它来自 上面的公式。我正试图从“数据”中重建公式

%看看傅里叶级数的前几个非常数项:

ListPlot[Table[Abs[Fourier[data]][[x]], {x,2,20}], PlotJoined->True, 
 PlotRange->All] 

显示预期峰值为6(因为周期数实际上是 25000/(623*2*Pi)或约6.38663,尽管我们不知道这一点)

%现在,我怎么才能找回6.38663?一种方法是使用 Cos[x]的任意倍数

convolve[n_] := Sum[data[[x]]*Cos[n*x], {x,1,25000}] 
%并绘制n=6附近的“卷积”图:

Plot[convolve[n],{n,5,7}, PlotRange->All] 

我们大致看到了预期的峰值

%我们尝试查找最大值:

FindMaximum[convolve[n],{n,5,7}] 
但结果是无用的和不准确的:

FindMaximum::fmmp:  
   Machine precision is insufficient to achieve the requested accuracy or 
    precision. 

Out[119]= {98.9285, {n -> 5.17881}} 
因为这个函数非常灵活

%通过优化我们的时间间隔(使用图形的视觉分析),我们可以 最后找到一个卷积[]不会摆动太多的间隔:

Plot[convolve[n],{n,6.2831,6.2833}, PlotRange->All] 

FindMaximum的工作原理是:

FindMaximum[convolve[n],{n,6.2831,6.2833}] // FortranForm 
List(1.984759605826571e7,List(Rule(n,6.2831853071787975))) 
%然而,这个过程是丑陋的,需要人为干预,并且 计算卷积[]非常慢。有更好的方法吗

%看看傅里叶级数的数据,我能不能预测出 “真实”期间数为6.38663?当然,实际结果如何 将是6.283185,因为我的数据更符合这一点(因为我只是
在有限数量的点进行采样)

使用自相关查找周期长度,以获得估计值:

autocorrelate[data_, d_] := 
 Plus @@ (Drop[data, d]*Drop[data, -d])/(Length[data] - d)

ListPlot[Table[{d, autocorrelate[data, d]}, {d, 0, 5000, 100}]]


智能搜索远离d=0的第一个最大值可能是从可用数据中获得的最佳估计值?

基于Mathematica傅里叶函数/应用程序/频率识别帮助: 检查版本7

n = 25000;
data = Table[N[753 + 919*Sin[x/623 - 125]], {x, 1, n}];
pdata = data - Total[data]/Length[data];
f = Abs[Fourier[pdata]];
pos = Ordering[-f, 1][[1]]; (*the position of the first Maximal value*)  
fr = Abs[Fourier[pdata Exp[2 Pi I (pos - 2) N[Range[0, n - 1]]/n], 
   FourierParameters -> {0, 2/n}]];
frpos = Ordering[-fr, 1][[1]];

N[(pos - 2 + 2 (frpos - 1)/n)]
返回6.37072


(* the data *) 

data = Table[N[753+919*Sin[x/623-125]], {x,1,25000}]; 

(* Find the position of the largest Fourier coefficient, after 
removing the last half of the list (which is redundant) and the 
constant term; the [[1]] is necessary because Ordering returns a list *) 

f2 = Ordering[Abs[Take[Fourier[data], {2,Round[Length[data]/2+1]}]],-1][[1]] 

(* Result: 6 *) 

(* Directly find the least squares difference between all functions of 
the form a+b*Sin[c*n-d], with intelligent starting values *) 

sol = FindMinimum[Sum[((a+b*Sin[c*n-d]) - data[[n]])^2, {n,1,Length[data]}], 
{{a,Mean[data]},{b,(Max[data]-Min[data])/2},{c,2*f2*Pi/Length[data]},d}] 

(* Result (using //InputForm):  

FindMinimum::sszero:  
   The step size in the search has become less than the tolerance prescribed by 
   the PrecisionGoal option, but the gradient is larger than the tolerance 
   specified by the AccuracyGoal option. There is a possibility that the method 
   has stalled at a point that is not a local minimum. 

{2.1375902350021628*^-19, {a -> 753., b -> -919., c -> 0.0016051364365971107,  
  d -> 2.477886509998064}} 

*) 


(* Create a table of values for the resulting function to compare to 'data' *) 

tab = Table[a+b*Sin[c*x-d], {x,1,Length[data]}] /. sol[[2]]; 

(* The maximal difference is effectively 0 *) 

Max[Abs[data-tab]] // InputForm 

(* Result: 7.73070496506989*^-12 *) 
虽然上面的内容不一定能完全回答我的问题,但我发现了 有点了不起

之前,我曾尝试将
FindFit[]
Method->NMinimize
(这是 本应提供更好的全球适应性),但效果并不理想, 可能是因为您无法给出
FindFit[]
智能起始值


我得到的错误让我感到厌烦,但似乎与此无关

我意识到这并没有解决标题中提出的问题,但它确实解决了在样本中查找周期数的问题。这很有趣,我正在研究它。我试图弄清楚自相关的作用,它是如何工作的,这是否有帮助,以及答案的含义。很好,你把一个非常摆动的函数变成了一个平滑的函数。自相关是将函数与自身关联起来——这有助于在你不知道周期的情况下找到重复的模式。傅里叶变换也可以有效地完成。也许你可以比我更好地帮助这个用户:你也可以使用
listcarrelate
来提高效率。太棒了!我按照“pos”(规范化数据并找到最大的傅里叶系数[由于规范化,常数项为0])的步骤进行操作,但是fr=线有什么魔力呢?这似乎是我所寻找的问题的关键。它再次在pdata*e^I(…)上进行傅里叶变换,并使用傅里叶变换的特性来计算校正/实现魔术。