2

Let's say I have an array of zeros:

a = numpy.zeros(1000)

I then introduce some repetitive 'events':

a[range(0, 1000, 30)] = 1

Question is, how do I detect the 'signal' there? Because it's far from the ideal signal if I do the 'regular' FFT I don't get a clear indication of where my 'true' signal is:

f = abs(numpy.fft.rfft(a))

Is there a method to detect these repetitions with some degree of certainty? Especially if I have few of those mixed in, for example here:

a[range(0, 1000, 30)] = 1
a[range(0, 1000, 110)] = 1
a[range(0, 1000, 48)] = 1

I'd like to get three 'spikes' on the resulting data...

4

2 に答える 2

3

自己相関の使用を検討しましたか?

于 2010-04-08T09:53:49.263 に答える
0

分析手法として、acf/pacf/ccf は時間依存信号の周期性を識別するために使用されるため、コレログラム (acf または pacf のグラフィカル表示) は、信号の自己相似性をさまざまなラグの関数として表示します。(したがって、たとえば、y 軸の値が 12 の遅れでピークに達し、日付が月単位である場合、それは年間の周期性の証拠です。)

「類似度」とラグを計算してプロットするには、自分でロールしたくない場合は、ネイティブの Numpy/Scipy オプションを知りません。また、「時系列」scikit (標準の Scipy ディストリビューションには含まれていないドメイン固有のモジュールである Scipy の「Scikits」のライブラリの 1 つ) にも見つかりませんでしたが、もう一度確認する価値があります。もう 1 つのオプションは、R への Python バインディング (RPy2、SourceForge で入手可能) をインストールすることです。これにより、時系列を渡して関数を呼び出すだけでコレログラムを計算およびプロットする' acf ' を含む、関連する R 関数にアクセスできるようになります。 .

一方、信号内の特定のタイプの連続した (途切れていない) ストリームを識別したい場合は、おそらく「ランレングス エンコーディング」が必要です。

import numpy as NP
signal = NP.array([3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,7,7,7,7,7,4,4,1,1,1,1,1,1,1])
px, = NP.where(NP.ediff1d(signal) != 0)
px = NP.r_[(0, px+1, [len(signal)])]
# collect the run-lengths for each unique item in the signal
rx = [ (m, n, signal[m]) for (m, n) in zip(px[:-1], px[1:]) ]

# returns [(0, 9, 3), (9, 19, 0), (19, 24, 7), (24, 26, 4), (26, 33, 1)]
# so w/r/t first 3-tuple: '3' occurs continuously in the half-open interval 0 and 9, and so forth
于 2010-04-08T11:49:10.733 に答える