sum of time series performace

I want to check the time series performance and have 150 trials in total and each trial is associated with either +1 or -1. I want o calculate it in such a way:
x=[mean(a(1:10)),mean(a(2:11)),mean(a(3:13)),mean(a(4:14)),........,mean(a(141:150))];

Answers (1)

Les Beckham
Les Beckham on 19 Oct 2022
Edited: Les Beckham on 19 Oct 2022
Your question isn't very clear but it appears that perhaps you want to do a moving average. Take a look at the documentation for the movmean function here: movmean
Possibly this would do what you want:
x = movmean(a, 10);

7 Comments

Thank you for the prompt response. I want to check the learning rates after averaging every ten trials with an increment of +1. For example first average the trial 1 to 10, second 2 to 11,......, 141 to 150. Hopefully this time it's clear.Please find attached
Thank you Beckham for the help. In my case it works as : M = movmean(a,10,'Endpoints','discard')
I'm not sure what you mean by "learning rates", but movmean does what you are describing.
load a.mat
figure
plot(a)
grid on
figure
plot(movmean(a, 10))
grid on
Thank you for the help and recommendation. In my case the following code works :
M = movmean(a,10,'Endpoints','discard')
But I need up to 2 decimal points and in this case there's zero after one decimal point.
Since you are dividing the sum of ten ones and negative ones by ten for each point in the moving average, it is expected that the result will be a multiple of 1/10, thus only "one decimal point".
If this answer helped solve your problem, please accept it. Thanks.
Thank you for the prompt response once again. But in this case, how I can get up to 2 decimal points? If there is any solution, please guide me
Les Beckham
Les Beckham on 19 Oct 2022
Edited: Les Beckham on 19 Oct 2022
There is no way you can sum up ten ones and negative ones and divide by ten and get anything that requires more than one decimal place to express. The answer is correct to two decimal places but the second decimal place is always going to be zero in this case.

Sign in to comment.

Categories

Tags

Edited:

on 19 Oct 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!