-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
525a2fc
commit f47684a
Showing
4 changed files
with
422 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
function zeroIfOutOfBound(i, f) { | ||
if (i < 0) { | ||
return 0; | ||
} | ||
if (i >= f.length - 1) { | ||
return 0; | ||
} | ||
return f[i]; | ||
} | ||
|
||
function phi(t, f) { | ||
var acc = 0; | ||
for (var i = 0; i < f.length; i++) { | ||
acc += f[i] * zeroIfOutOfBound(i + t, f); | ||
} | ||
return acc; | ||
} | ||
|
||
export default function autocorrelation() { | ||
if (typeof arguments[0].signal !== 'object') { | ||
throw new TypeError(); | ||
} | ||
|
||
const arr = arguments[0].signal; | ||
|
||
var ac = new Float32Array(arr.length); | ||
for (var lag = 0; lag < arr.length; lag++) { | ||
var value = 0; | ||
for (var index = 0; index < arr.length - lag; index++) { | ||
let a = arr[index]; | ||
let otherindex = index - lag; | ||
let b = otherindex >= 0 ? arr[otherindex] : 0; | ||
value = value + a * b; | ||
} | ||
ac[lag] = value; | ||
var ac = new Float32Array(arr.length*2); | ||
for (var lag = -1*arr.length; lag < arr.length; lag++) { | ||
ac[lag + arr.length] = phi(lag, arr); | ||
} | ||
return ac; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
[ | ||
-1.42108547152020e-14, | ||
-7.10542735760100e-15, | ||
-0.00244567041421462, | ||
-0.00977071172614785, | ||
-0.0243849284966942, | ||
-0.0486623911059354, | ||
-0.0849297287379613, | ||
-0.135454596689161, | ||
-0.202434360511617, | ||
-0.287985038794869, | ||
-0.394130545544929, | ||
-0.522792272139455, | ||
-0.675779047728387, | ||
-0.854777515710488, | ||
-1.06134296255421, | ||
-1.29689063374909, | ||
-1.56268757007610, | ||
-1.85984499567782, | ||
-2.18931128759575, | ||
-2.55186555452970, | ||
-2.94811185056717, | ||
-3.37847404753721, | ||
-3.84319138746754, | ||
-4.34231473437423, | ||
-4.87570354229648, | ||
-5.44302355411090, | ||
-6.04374524323028, | ||
-6.67714300781490, | ||
-7.34229512461187, | ||
-8.03808446699316, | ||
-8.76319998919854, | ||
-9.51613897620849, | ||
-10.2952100560873, | ||
-11.0985369690516, | ||
-11.9240630849471, | ||
-12.7695566582587, | ||
-13.6326168072514, | ||
-14.5106802013424, | ||
-15.4010284383533, | ||
-16.3007960908852, | ||
-17.2069793987153, | ||
-18.1164455818314, | ||
-19.0259427465115, | ||
-19.9321103547260, | ||
-20.8314902250954, | ||
-21.7205380316877, | ||
-22.5956352650847, | ||
-23.4531016184022, | ||
-24.2892077593126, | ||
-25.1001884475991, | ||
-25.8822559563738, | ||
-26.6316137538198, | ||
-27.3444704011781, | ||
-28.0170536216936, | ||
-28.6456244943677, | ||
-29.2264917256394, | ||
-29.7560259515351, | ||
-30.2306740223939, | ||
-30.6469732219889, | ||
-31.0015653727292, | ||
-31.2912107786457, | ||
-31.5128019580274, | ||
-31.6633771178998, | ||
-31.7401333230047, | ||
-31.7404393125664, | ||
-31.6618479188988, | ||
-31.5021080428320, | ||
-31.2591761420008, | ||
-30.9312271892489, | ||
-30.5166650597522, | ||
-30.0141323069534, | ||
-29.4225192890193, | ||
-28.7409726092823, | ||
-27.9689028360000, | ||
-27.1059914687628, | ||
-26.1521971209804, | ||
-25.1077608900986, | ||
-23.9732108895073, | ||
-22.7493659185186, | ||
-21.4373382492873, | ||
-20.0385355121320, | ||
-18.5546616633674, | ||
-16.9877170224825, | ||
-15.3399973682757, | ||
-13.6140920863955, | ||
-11.8128813636002, | ||
-9.93953242696585, | ||
-7.99749482919823, | ||
-5.99049478415788, | ||
-3.92252855966355, | ||
-1.79785493759712, | ||
0.379013245719522, | ||
2.60331846297551, | ||
4.87006874434794, | ||
7.17404878933619, | ||
9.50983191746370, | ||
11.8717928305889, | ||
14.2541211568609, | ||
16.6508357437184, | ||
19.0557996647744, | ||
21.4627359029557, | ||
23.8652436698913, | ||
26.2568153192672, | ||
28.6308538097010, | ||
30.9806906706369, | ||
33.2996044228404, | ||
35.5808394032680, | ||
37.8176249424325, | ||
40.0031948408579, | ||
42.1308070898486, | ||
44.1937637805718, | ||
46.1854311443872, | ||
48.0992596664520, | ||
49.9288042138837, | ||
51.6677441191918, | ||
53.3099031592791, | ||
54.8492693700805, | ||
56.2800146368497, | ||
57.5965140002118, | ||
58.7933646183972, | ||
59.8654043265336, | ||
60.8077297345164, | ||
61.6157138057949, | ||
62.2850228604027, | ||
62.8116329467228, | ||
63.1918455278116, | ||
63.4223024296059, | ||
63.5000000000004, | ||
63.4223024296060, | ||
63.1918455278116, | ||
62.8116329467228, | ||
62.2850228604027, | ||
61.6157138057949, | ||
60.8077297345164, | ||
59.8654043265336, | ||
58.7933646183972, | ||
57.5965140002118, | ||
56.2800146368497, | ||
54.8492693700805, | ||
53.3099031592790, | ||
51.6677441191918, | ||
49.9288042138837, | ||
48.0992596664520, | ||
46.1854311443872, | ||
44.1937637805718, | ||
42.1308070898486, | ||
40.0031948408579, | ||
37.8176249424325, | ||
35.5808394032680, | ||
33.2996044228404, | ||
30.9806906706369, | ||
28.6308538097010, | ||
26.2568153192672, | ||
23.8652436698913, | ||
21.4627359029557, | ||
19.0557996647744, | ||
16.6508357437184, | ||
14.2541211568609, | ||
11.8717928305889, | ||
9.50983191746370, | ||
7.17404878933620, | ||
4.87006874434794, | ||
2.60331846297551, | ||
0.379013245719522, | ||
-1.79785493759712, | ||
-3.92252855966355, | ||
-5.99049478415787, | ||
-7.99749482919823, | ||
-9.93953242696585, | ||
-11.8128813636002, | ||
-13.6140920863955, | ||
-15.3399973682757, | ||
-16.9877170224825, | ||
-18.5546616633674, | ||
-20.0385355121320, | ||
-21.4373382492873, | ||
-22.7493659185186, | ||
-23.9732108895073, | ||
-25.1077608900986, | ||
-26.1521971209804, | ||
-27.1059914687628, | ||
-27.9689028360000, | ||
-28.7409726092823, | ||
-29.4225192890193, | ||
-30.0141323069534, | ||
-30.5166650597522, | ||
-30.9312271892489, | ||
-31.2591761420008, | ||
-31.5021080428320, | ||
-31.6618479188988, | ||
-31.7404393125664, | ||
-31.7401333230047, | ||
-31.6633771178998, | ||
-31.5128019580274, | ||
-31.2912107786457, | ||
-31.0015653727292, | ||
-30.6469732219889, | ||
-30.2306740223939, | ||
-29.7560259515351, | ||
-29.2264917256394, | ||
-28.6456244943677, | ||
-28.0170536216936, | ||
-27.3444704011781, | ||
-26.6316137538198, | ||
-25.8822559563738, | ||
-25.1001884475991, | ||
-24.2892077593126, | ||
-23.4531016184022, | ||
-22.5956352650847, | ||
-21.7205380316877, | ||
-20.8314902250954, | ||
-19.9321103547260, | ||
-19.0259427465115, | ||
-18.1164455818314, | ||
-17.2069793987153, | ||
-16.3007960908852, | ||
-15.4010284383533, | ||
-14.5106802013424, | ||
-13.6326168072514, | ||
-12.7695566582587, | ||
-11.9240630849471, | ||
-11.0985369690516, | ||
-10.2952100560873, | ||
-9.51613897620849, | ||
-8.76319998919854, | ||
-8.03808446699316, | ||
-7.34229512461186, | ||
-6.67714300781490, | ||
-6.04374524323027, | ||
-5.44302355411090, | ||
-4.87570354229649, | ||
-4.34231473437423, | ||
-3.84319138746754, | ||
-3.37847404753720, | ||
-2.94811185056717, | ||
-2.55186555452970, | ||
-2.18931128759576, | ||
-1.85984499567782, | ||
-1.56268757007611, | ||
-1.29689063374910, | ||
-1.06134296255422, | ||
-0.854777515710484, | ||
-0.675779047728383, | ||
-0.522792272139455, | ||
-0.394130545544932, | ||
-0.287985038794872, | ||
-0.202434360511617, | ||
-0.135454596689165, | ||
-0.0849297287379613, | ||
-0.0486623911059407, | ||
-0.0243849284967013, | ||
-0.00977071172615140, | ||
-0.00244567041421462, | ||
-5.32907051820075e-15, | ||
-1.42108547152020e-14 | ||
] |
Oops, something went wrong.