4
$\begingroup$

I have one set of original data (signal A) and a second set of derived data (signal B) which was computed from A by position rotation (circular shift).

Here are the data for the signals (A and B):

 A={0.000687529, 0.000469275, 0.000398264, 0.000452097, 0.000707831, \
    0.000843552, 0.00109763, 0.00129248, 0.00155505, 0.00175328, \
    0.00185787, 0.00199521, 0.00217107, 0.00237594, 0.00260796, \
    0.00287782, 0.00305717, 0.0032379, 0.00331642, 0.00345246, \
    0.00359661, 0.00374097, 0.00388378, 0.00402907, 0.00415421, \
    0.00434188, 0.00451071, 0.00455313, 0.00472354, 0.00479159, \
    0.00498119, 0.00523115, 0.00536973, 0.00548327, 0.00560835, \
    0.00568071, 0.005826, 0.00591612, 0.0060792, 0.0062144, 0.00632866, \
    0.00648129, 0.00664242, 0.00661467, 0.00646406, 0.00635145, \
    0.0061808, 0.00601821, 0.00588936, 0.0057433, 0.00567009, 0.00579234, \
    0.00606283, 0.0062075, 0.00643594, 0.00674731, 0.00693473, \
    0.00712268, 0.00734985, 0.00757761, 0.00784752, 0.00809828, \
    0.00830859, 0.00848268, 0.00855698, 0.00853184, 0.00843628, \
    0.00840713, 0.00828257, 0.00812343, 0.00786293, 0.00760314, \
    0.00735534, 0.00715276, 0.0068602, 0.00669293, 0.00650898, \
    0.00633127, 0.00621235, 0.00601095, 0.00585806, 0.00566508, \
    0.00537764, 0.00518755, 0.00490508, 0.00467247, 0.00448708, \
    0.00421288, 0.00403308, 0.00380989, 0.00358435, 0.00336725, \
    0.00314628, 0.00291536, 0.00276355, 0.00259346, 0.00250392, \
    0.00240535, 0.00228834, 0.00223278, 0.00216968, 0.00211373, \
    0.00210138, 0.00204944, 0.00200335, 0.00206679, 0.00219473, \
    0.0023426, 0.00244453, 0.00261942, 0.00279737, 0.00299706, \
    0.00319045, 0.003328, 0.00354889, 0.0037978, 0.00400903, 0.00422245, \
    0.00435909, 0.00460264, 0.00484907, 0.00506072, 0.0052928, 0.0055346, \
    0.00576666, 0.00597143, 0.00616593, 0.0063511, 0.00653763, \
    0.00674774, 0.00692797, 0.00718014, 0.00734131, 0.00753652, \
    0.00770509, 0.00784182, 0.0080506, 0.00813282, 0.00815429, \
    0.00815281, 0.00821125, 0.00819513, 0.0081484, 0.00802883, \
    0.00798239, 0.00782902, 0.0076799, 0.00753525, 0.00743772, \
    0.00738916, 0.00736425, 0.00730045, 0.00725698, 0.0071917, \
    0.00720083, 0.00719242, 0.0071638, 0.00710055, 0.0071072, 0.00707563, \
    0.00711125, 0.00705156, 0.00704075, 0.00703061, 0.00688556, \
    0.00674653, 0.0065152, 0.00638235, 0.00624859, 0.00602397, \
    0.00579689, 0.00552445, 0.00529913, 0.00502276, 0.00475309, \
    0.00452354, 0.00425615, 0.00399083, 0.00376345, 0.00357221, \
    0.00344024, 0.00336814, 0.00331128, 0.00327403, 0.00330657, \
    0.00327187, 0.00333636, 0.00330469, 0.00307137, 0.00288557, \
    0.00272025, 0.00249407, 0.00226909, 0.00200222, 0.00192721, \
    0.00170829, 0.00149336, 0.00138367, 0.00113125, 0.000898223}


B ={0.00179133, 0.00166371, 0.00144427, 0.00127476, 0.00111167, \
0.000875955, 0.000680859, 0.000488182, 0.000453931, 0.000489739, \
0.000680628, 0.000853867, 0.00111138, 0.00135699, 0.00160312, \
0.00178946, 0.0019235, 0.00216743, 0.00243426, 0.00266385, \
0.00282936, 0.00307688, 0.00326293, 0.00345118, 0.00360717, \
0.00386439, 0.00402533, 0.00428551, 0.00448164, 0.00458266, \
0.00484556, 0.00504418, 0.00529953, 0.00542256, 0.0054878, \
0.00556376, 0.00566811, 0.00573164, 0.00585149, 0.005949, 0.00601323, \
0.00614443, 0.00627285, 0.00639037, 0.00649202, 0.00655822, \
0.00652702, 0.00639897, 0.00629227, 0.00617542, 0.00603389, \
0.00594053, 0.00579678, 0.00571396, 0.00559096, 0.00565505, \
0.00587221, 0.00610551, 0.00625315, 0.00644118, 0.00672644, \
0.00690851, 0.00714852, 0.00736986, 0.00759197, 0.00781478, \
0.00799256, 0.00821238, 0.00838457, 0.00842187, 0.00841158, \
0.0083638, 0.00832124, 0.00819612, 0.00797337, 0.00774812, \
0.00752342, 0.00725363, 0.00702523, 0.00683774, 0.00661432, \
0.00649465, 0.00626664, 0.00614924, 0.00594457, 0.00574326, \
0.00557751, 0.00531227, 0.00506177, 0.00484326, 0.00458248, \
0.00436655, 0.0040842, 0.00387318, 0.0036644, 0.00341739, 0.0032151, \
0.0029776, 0.00282311, 0.00265499, 0.00247667, 0.00235499, \
0.00225116, 0.00214566, 0.00210722, 0.00205865, 0.00200885, \
0.00198284, 0.00194453, 0.00192483, 0.00202486, 0.0021459, \
0.00232546, 0.00249348, 0.00265304, 0.00285085, 0.00306639, \
0.00325244, 0.00347692, 0.00367492, 0.00391185, 0.00404695, \
0.00429086, 0.00447472, 0.00465098, 0.00487914, 0.00505841, \
0.00531235, 0.00547795, 0.00566877, 0.00589804, 0.00607675, \
0.00631952, 0.00651414, 0.0066481, 0.00682482, 0.00696432, 0.0071265, \
0.00733279, 0.00746036, 0.00763356, 0.00776814, 0.00794871, \
0.00804627, 0.00807328, 0.00812335, 0.00810701, 0.00808732, \
0.00805859, 0.00802379, 0.00784984, 0.00773894, 0.00762459, \
0.00746838, 0.00740464, 0.00734782, 0.00729826, 0.00720739, \
0.00721521, 0.00717758, 0.00711063, 0.00712693, 0.00706925, \
0.0070561, 0.00708326, 0.00704501, 0.0070471, 0.00698018, 0.00689255, \
0.00679343, 0.00655189, 0.00639836, 0.0062231, 0.00601383, \
0.00582787, 0.00555936, 0.00533303, 0.0050666, 0.00494473, 0.004699, \
0.00447582, 0.00429352, 0.00407246, 0.00385296, 0.00364865, \
0.00342754, 0.00338171, 0.00332807, 0.0032759, 0.00325762, \
0.00329416, 0.00326733, 0.00330265, 0.0032649, 0.00303984, \
0.00284934, 0.00261731, 0.00233832, 0.00215401, 0.00192621}

A and B are normalized.

ListPlot[{A,B},Joined->True]

enter image description here

I applied Fourier to calculate the spectrum of A and B; I expected the results to be equal, but they weren't. I suspect I'm not using Fourier properly to examine my signals.

enter image description here

Why don't the results for the shifted signal match the original?

$\endgroup$
  • $\begingroup$ Try with {} as in ListPlot[{Abs[Fourier[A]]^2,Abs[Fourier[B]]^2}]. $\endgroup$ – b.gates.you.know.what Nov 1 '14 at 15:57
  • $\begingroup$ @b.gatessucks,thanks but it was just a mistype. $\endgroup$ – BetterEnglish Nov 1 '14 at 16:06
  • $\begingroup$ @b.gatessucks, I think the problem is form the Fourier[]. I don't use it properly. $\endgroup$ – BetterEnglish Nov 1 '14 at 16:09
  • $\begingroup$ @Developer2000, almost but not exactly shifted, try ListPlot[RotateRight[A, 5 ] - B, PlotRange -> All] $\endgroup$ – alancalvitti Nov 1 '14 at 18:28
  • $\begingroup$ If I understand correctly, I see nothing strange: the signals are not perfectly identical, why would the spectrum be exactly the same? $\endgroup$ – anderstood Feb 18 '15 at 22:32
7
$\begingroup$

A couple things are at play here. First, you say "A and B are normalized", but this is false:

A.A
B.B
(*0.00597401*)
(*0.00595062*)

Second, you say B is a shifted version of A, but this is also false:

ListLinePlot[Table[Norm[RotateRight[A, k] - B], {k, 0, 10}], 
 PlotRange -> All, PlotMarkers -> Automatic]

enter image description here

In particular, there is a 1.9 degree angle between A and rotated B in $N$-space:

VectorAngle[RotateRight[A, 5], B]*180/\[Pi]
(*1.94413*)

This discrepancy is what causes the small differences between the magnitude spectra of the two datasets.

Note that since the Fourier transform is a geometric isometry, the angle is preserved, and this angle difference is what you're seeing:

VectorAngle[Fourier[RotateRight[A, 5]], Fourier[B]] 180/\[Pi]
(*1.94413 - 2.54444*10^-14 I*)
$\endgroup$
  • $\begingroup$ Thanks,A and B are normalized. check Total[A]=1. and Total[B]=1. Yes B is rotated not shifted. $\endgroup$ – BetterEnglish Nov 1 '14 at 21:20
  • 2
    $\begingroup$ @Developer2000: No, that's not what normalization means. Normalization means the norm is 1, not the total is 1. However, the normalization isn't the problem, the problem is that the datasets aren't the same even when the rotation is taken in to account. Your understanding of Fourier is perfectly correct; if two datasets are equivalent up to rotation, then their magnitude spectra are the same. So you are using Fourier properly. The problem is there is something wrong with your data. $\endgroup$ – DumpsterDoofus Nov 1 '14 at 22:01
5
$\begingroup$

Here's how the rotational property should work. Let a be a list and let b be a version of the list that is rotated (in this case by 10). Then Abs[Fourier[a]] and Abs[Fourier[b]] should be equal.

a = RandomReal[{-1, 1}, {100}];
b = RotateRight[a, 10];
Total[Abs[Abs[Fourier[a]] - Abs[Fourier[b]]]]

9.47159*10^-15

As you can see, they are not exactly equal -- and this is because of numerical roundoff. Almost any time you do an FFT (i.e., use the Fourier[] command), you will see such numerical errors, which show up here as about 10^-14.

Note that this kind of rotation (circular shift, actually) is not the same as a spatial rotation such as taking an image and rotating it by 10 degrees.

$\endgroup$
  • $\begingroup$ Yes I see. Thanks. $\endgroup$ – BetterEnglish Nov 2 '14 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.