Message Boards Message Boards

1
|
3900 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Short-term noises and Gradient for a time series?

Posted 4 years ago

Hi,

I am a new member of the Wolfram community and happy to be a part of this community.

For each point of the time series, the short-term noises are calculated as the percentage of deviation of the observation cp(t) over the short-term moving average of the series cp(t). Also, the short-term gradients are calculated as the percentage of changes in the moving average. Is my solution right for the sample time series?

cpt = {19.5`, 61.1`, 17.2`, 56.1`, 4.1`, 8.`, 7.5`, 18.1`, 27.`, 
   48.4`, 30.7`, 11.`, 66.5`, 60.7`, 0.4`, 3.`, 8.2`, 22.5`, 21.6`, 
   48.3`, 114.7`, 436.`, 237.7`, 55.`, 69.5`, 42.`, 13.6`, 33.9`, 
   0.3`, 16.4`, 54.2`, 83.8`, 100.2`, 706.6`, 105.8`, 54.3`, 85.9`, 
   81.8`, 46.5`, 5.6`, 9.3`, 7.4`, 6.2`, 23.2`, 27.`, 215.6`, 668.6`, 
   44.6`, 119.2`, 58.8`, 27.1`, 14.1`, 11.2`, 52.4`, 0.7`, 3.8`, 
   44.8`, 50.1`, 86.9`, 513.7`, 64.5`, 136.1`, 69.7`, 25.9`, 70.7`, 
   28.3`, 15.7`, 37.1`, 23.`, 22.`, 63.9`, 51.9`, 608.8`, 34.8`, 
   109.6`, 29.4`, 39.4`, 43.7`, 46.1`, 28.`, 8.7`, 4.5`, 82.2`, 20.`, 
   1.4`, 447.8`, 75.6`, 164.2`, 10.5`, 37.2`, 33.8`, 22.4`, 10.8`, 
   22.4`, 32.5`, 23.6`, 35.3`, 468.3`, 45.9`, 68.1`, 41.7`, 33.7`, 
   22.2`, 5.2`, 32.4`, 11.7`, 14.3`, 38.7`, 62.9`, 376.8`, 82.4`, 
   49.5`, 46.8`, 25.9`, 52.5`, 21.9`, 4.5`, 6.7`, 11.5`, 50.8`, 85.2`,
    46.1`, 483.8`, 93.`, 54.9`, 37.3`, 74.3`, 58.3`, 22.2`, 3.3`, 
   3.3`, 73.2`, 51.5`, 176.3`, 647.6`, 73.6`, 40.2`, 212.`, 27.9`, 
   30.6`, 3.7`, 72.4`, 32.2`, 1.4`, 2.2`, 0.`, 82.9`, 102.1`, 109.`, 
   676.4`, 178.`, 39.6`, 110.`, 29.6`, 8.3`, 0.9`, 10.3`, 31.4`, 
   11.2`, 43.5`, 123.`, 585.8`, 327.6`, 66.9`, 45.9`, 7.2`, 61.6`, 
   15.2`, 1.`, 10.5`, 0.6`, 8.7`, 82.9`, 110.`, 738.1`, 58.9`, 44.4`, 
   41.6`, 56.3`, 6.3`, 49.4`, 1.5`, 22.6`, 18.1`, 31.1`, 12.9`, 54.2`,
    397.3`, 89.7`, 91.4`, 66.5`, 43.8`, 33.2`, 37.6`, 103.4`, 1.`, 
   8.4`, 7.7`, 104.3`, 138.6`, 725.6`, 121.1`, 45.6`, 81.3`, 64.4`, 
   3.9`, 3.2`, 16.4`, 2.9`, 20.3`, 96.6`, 17.2`, 472.9`, 182.5`, 
   84.6`, 57.4`, 10.7`, 26.9`, 9.2`, 4.1`, 11.7`, 38.8`, 79.`, 30.6`, 
   535.5`, 116.7`, 80.1`, 6.6`, 8.9`, 47.4`, 32.3`, 3.1`, 39.3`, 
   61.4`, 28.3`, 12.8`, 83.9`, 520.8`, 44.5`, 27.`, 63.3`, 31.4`, 
   26.4`, 44.9`, 17.8`, 0.1`, 13.3`, 44.2`, 116.6`, 429.5`, 11.5`, 
   107.2`, 152.9`, 37.6`, 22.4`, 0.`, 8.5`, 40.8`, 0.5`, 33.7`, 
   108.9`, 92.4`, 616.4`, 5.2`, 7.1`, 38.8`, 0.6`, 15.5`, 8.3`, 9.`, 
   30.1`, 91.7`, 44.8`, 251.1`, 3.`, 58.`, 25.3`, 16.9`, 19.1`, 2.6`, 
   0.5`, 8.`, 4.4`, 26.`, 114.2`, 278.`, 58.7`, 21.5`, 29.8`, 50.3`, 
   21.6`, 0.2`, 49.5`, 14.3`, 9.9`, 48.4`, 30.5`, 136.4`, 471.1`, 6.`,
    62.2`, 42.5`, 22.3`, 14.8`, 17.7`, 31.6`, 3.1`, 29.8`, 77.5`, 
   307.5`, 42.7`, 66.4`, 82.3`, 6.8`, 86.2`, 7.6`, 2.6`, 1.1`, 76.3`, 
   62.9`, 434.9`, 88.8`, 57.8`, 44.9`, 19.3`, 46.8`, 12.3`, 9.1`, 
   1.8`, 16.8`, 56.4`, 102.1`, 49.4`, 505.5`, 92.1`, 23.4`, 126.`, 
   15.8`, 21.9`, 26.`, 27.3`, 0.3`, 46.1`, 69.8`, 34.2`, 482.9`, 
   18.6`, 132.6`, 42.1`, 34.3`, 28.3`, 16.7`, 13.5`, 5.9`, 26.3`, 
   38.`, 134.4`, 490.7`, 33.4`, 20.9`, 50.2`, 65.7`, 16.8`, 25.8`, 
   18.8`, 11.4`, 66.7`, 79.`, 116.`, 504.7`, 50.7`, 37.1`, 124.1`, 
   84.7`, 41.7`, 33.4`, 4.1`, 18.4`, 10.9`, 96.5`, 121.6`, 623.2`, 
   166.`, 154.7`, 53.5`, 30.6`, 1.9`, 60.8`, 41.8`, 31.5`, 13.7`, 
   5.2`, 10.`, 46.`, 615.7`, 60.2`, 77.1`, 89.2`, 50.4`, 52.4`, 12.8`,
    1.5`, 2.8`, 6.6`, 15.7`, 76.4`, 32.5`, 477.6`, 12.`, 79.1`, 2.`, 
   54.7`, 38.1`, 0.6`, 27.9`, 32.7`, 0.5`, 5.6`, 125.8`, 238.9`, 
   617.9`, 67.9`, 27.9`, 80.8`, 90.5`, 16.6`, 13.`, 4.8`, 13.9`, 
   76.2`, 32.6`, 60.1`, 154.9`, 639.2`, 76.3`, 143.3`, 76.2`, 100.5`, 
   77.8`, 17.`, 4.2`, 55.2`, 7.1`, 110.`, 667.6`, 215.6`, 54.7`, 8.1`,
    82.4`, 16.6`, 4.8`, 1.8`, 17.7`, 17.8`, 11.9`, 53.4`, 18.1`, 
   502.9`, 28.4`, 68.9`, 18.5`, 19.2`, 37.8`, 14.2`, 6.8`, 0.4`, 
   26.8`, 43.`, 79.`, 67.4`, 410.4`, 61.`, 55.6`, 111.5`, 63.8`, 
   36.9`, 38.1`, 11.3`, 8.6`, 31.2`, 65.1`, 46.`, 4.2`, 533.3`, 83.1`,
    73.8`, 20.2`, 35.7`, 16.3`, 27.6`, 16.`, 0.5`, 69.1`, 57.7`, 
   108.9`, 148.4`, 7.`, 25.1`, 41.9`, 48.`, 9.6`, 0.1`, 8.4`, 9.1`, 
   30.`, 15.`, 67.6`, 19.9`, 281.7`, 187.7`, 142.4`, 61.8`, 71.7`, 
   69.2`, 30.9`, 29.1`, 6.4`, 36.1`, 27.4`, 91.7`, 151.1`, 905.5`, 
   89.5`, 131.2`, 11.5`, 50.9`, 37.7`, 35.8`, 8.`, 1.2`, 1.5`, 72.4`, 
   20.8`, 127.3`, 587.8`, 95.`, 87.8`, 25.1`, 60.9`, 57.6`, 37.1`, 
   5.`, 5.2`, 66.4`, 2.8`, 61.5`, 504.4`, 155.5`, 155.5`};

enter image description here

POSTED BY: Alex Teymouri
2 Replies
Posted 4 years ago

Dear Prof.Namjoshi,

Thanks a lot.

POSTED BY: Updating Name
Posted 4 years ago

Hi Alex,

For any window size greater than one, MovingAverage is going to generate a list that is shorter than the input.

Length /@ {cpt, MovingAverage[cpt, 2]}
(* {549, 548} *)

So the two lists cannot be term-wise subtracted. Ignoring the last element of cpt

(Most[cpt] - MovingAverage[cpt, 2]) / MovingAverage[cpt, 2]

Also, in the gradient code, take a look at the result of cpt - 1. One is subtracted from each element, it is not an offset. Try Span.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract