You can get my data by this code
{data1, data2} = Uncompress[FromCharacterCode@
Flatten[ImageData[Import["https://i.sstatic.net/ShSMY.png"], "Byte"]]];
We can show it with ListLinePlot
ListLinePlot[{data1, data2}, PlotRange -> All]
Note the peaks of data1
and data2
is not same totally.I want to calculate the amount of offset in x-axis direction after we align data1
and data2
as far as possible.This current try
offset = Length[data1] -
SmithWatermanSimilarity @@ (PeakDetect[Last /@ #] & /@ {data1,data2});
First[Commonest[Differences[First /@ data1]]]*offset
17.4
As we can see,the error is very big.I think two diffcult in this solution result to this
The x-interval is not exactly same.
Union[Differences[First /@ data1]]
{0.01,0.02,0.02,0.02,0.02,0.02,0.03,0.03}(*funny to get so many 0.02.*)
The peak is not exactly same.
Is there any better method can do this?