0

Let say, I have 3-time series. with value of

a = [1, 2, 4, 5, 3, 1 ]
b = [3, 5, 2, 9, 3, 1]
c = [2, 5, 6, 7, 3, 1]

now I want to rate the deviation of values from each time series. for example, 2nd values of all-time series 2, 5, 5, and it "mean" values are 4 and deviation from mean is 2, -1, -1. I want to say anything <0 bad, 0 is ok and >0 is good. So for 2nd element rating would good, bad, bad in this example.

Now if I want to rate, the 3rd element in a similar way, it would be

mean= 4 
deviation = 0, 2, -2
rating = ok, good, bad

Now my question is I want to rate the 3rd element considering the rating of the 2nd element. And continue in a similar fashion. Sorry for basic questions, but any proven method where this can be done effectively and successfully would be really helpful. python related handbook link is also appreciated.

2 Answers2

0

In R, maybe you can do it like below

df <- data.frame(a,b,c)
f <- function(v) {
    list(
        Mean = mean(v),
        Deviation = v - mean(v),
        rating = c("bad","ok","good")[sign(v-mean(v))+2]
    )
}
res <- apply(df,1,f)

such that

> res
[[1]]
[[1]]$Mean
[1] 2

[[1]]$Deviation
 a  b  c
-1  1  0 

[[1]]$rating
[1] "bad"  "good" "ok"  


[[2]]
[[2]]$Mean
[1] 4

[[2]]$Deviation
 a  b  c
-2  1  1 

[[2]]$rating
[1] "bad"  "good" "good"


[[3]]
[[3]]$Mean
[1] 4

[[3]]$Deviation
 a  b  c
 0 -2  2

[[3]]$rating
[1] "ok"   "bad"  "good"


[[4]]
[[4]]$Mean
[1] 7

[[4]]$Deviation
 a  b  c
-2  2  0 

[[4]]$rating
[1] "bad"  "good" "ok"


[[5]]
[[5]]$Mean
[1] 3

[[5]]$Deviation
a b c
0 0 0

[[5]]$rating
[1] "ok" "ok" "ok"


[[6]]
[[6]]$Mean
[1] 1

[[6]]$Deviation
a b c
0 0 0

[[6]]$rating
[1] "ok" "ok" "ok"

Data

a = c(1, 2, 4, 5, 3, 1 )
b = c(3, 5, 2, 9, 3, 1)
c = c(2, 5, 6, 7, 3, 1)
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
0

If I understand correctly, you want to express the ratings for a column i, in terms of the ratings for column i-1.

If this correct, I don't think this is possible unless the values in the time series are dependent on previous values in some deterministic sense. Since this does not seem to be the case, you are out of luck.

If you just want the rating of the previous column to influence the rating of the current column, you just have to think of some rule that is relevant to your use of the ratings.

  • Thanks for the answer.. You got my question perfectly. Currently I am just averaging the rating of the i-th number based on i-1 th number.. But I was actually looking for something concrete that will backup the idea. Thanks again! – Hydro Modeler May 11 '20 at 13:47