移動平均我想在一列,每100點的平均值,然後將平均在中間 - 在點50用awk
我嘗試使用這個腳本計算移動平均線:
BEGIN {
P = 100;
}
{
x = $2;
i = NR % P;
MA += (x - Z[i])/P;
Z[i] = x;
print $1,"\t",$2,"\t",MA;
}
但我需要知道如何將它放在中間?
樣品輸入:
Depth Velocity
1150.315 434.929
1150.468 434.929
1150.62 434.929
1150.772 434.929
1150.925 434.929
1151.077 434.929
1151.23 434.929
1151.382 434.929
1151.534 434.929
1151.687 434.929
1151.839 434.929
1151.992 434.929
1152.144 434.929
1152.296 434.929
1152.449 434.929
1152.601 434.929
1152.754 434.929
1152.906 434.929
1153.058 434.929
1153.211 434.929
1153.363 434.929
1153.516 434.929
1153.668 434.929
1153.82 434.929
1153.973 434.929
1154.125 434.929
1154.278 434.929
1154.43 434.929
1154.582 434.929
1154.735 434.929
1154.887 434.929
1155.04 434.929
1155.192 434.929
1155.344 434.929
1155.497 434.929
1155.649 434.517
1155.802 434.105
1155.954 433.693
1156.106 433.233
1156.259 432.773
1156.411 432.313
1156.564 431.853
1156.716 431.853
1156.868 431.853
1157.021 431.853
1157.173 431.853
1157.326 431.853
1157.478 431.853
1157.63 431.853
1157.783 431.853
1157.935 431.853
1158.088 431.853
1158.24 431.853
1158.392 431.853
1158.545 431.853
1158.697 431.853
1158.85 431.853
1159.002 431.853
1159.154 432.642
1159.307 433.431
1159.459 434.221
1159.612 437.791
1159.764 441.363
1159.916 444.933
1160.069 448.505
1160.221 448.037
1160.374 447.569
1160.526 447.101
1160.678 455.151
1160.831 463.208
1160.983 471.259
1161.136 473.544
1161.288 475.826
1161.44 478.111
1161.593 465.778
1161.745 453.435
...... .......
輸出應該是深度和平滑的速度 - 平均 - 和第一個和最後50分將被刪除。
對於'P = 2'的情況,你能顯示你的輸入和預期的輸出應該是什麼樣子嗎? –