cumulative maximum loss code

I'm new to Matlab and I'm having trouble with the code for the computation of cumulative maximum loss for a time series. What I need to do is to compute the maximum loss compared to the highest levels of the variable over a period T which is set to 522 days.
Specifically,
.
Thank you for any help

답변 (1개)

Koushik Vemula
Koushik Vemula 2020년 3월 9일

0 개 추천

According to my understanding you have a variable x’ which has ‘n(say) number of values.
You would like to find the value of
where the value 522 is T’ value.
You can do it in the following manner
1-(x(t))/max(x(1:T+1))
We have ‘+1’ as matlab index starts from ‘1

댓글 수: 6

Alex
Alex 2020년 3월 11일
Thank you for your reply.
I'm going to explain better. The time series x has t daily observations (let's say t=10,000), and for each observation I want to find this value. Obviously for the first 522 observations it wouldn't be possible.
Koushik Vemula
Koushik Vemula 2020년 3월 11일
so you want to compare the observations from x(t) to x(t-T) for all the values of t > T
Alex
Alex 2020년 3월 11일
Let's take for example observation 560. For that observation I need to compute the value as . An that for all observations. So for each obs I need to consider the 522 observations before that and find the maximum value among these obs, then to compute the final expression.
you can do that in this manner (let us take 560 for example)
1-(x(560)/max(x(560-522:560)))
This will check the values from x38 to x560 and takes the max value of it as the denominator
Alex
Alex 2020년 3월 13일
Thank you, what about doing that in loop for all the observations of the time series?
for i = T+1:length(x)
sol(i)=1-(x(i)/max(x(i-T:i)))
end
Here we are iterating from T+1 (index should be greater than 0) to max of x.
This will give you your desired result

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2020년 3월 6일

댓글:

2020년 3월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by