2016-09-25 50 views
0

我想更改成本函數的默認步長模式權重,因爲我需要在不使用紙張的情況下將其結果與其他人的標準化結果進行標準化對角線距離的權重2。我讀過JSS paper,但我發現其他步驟模式並非我真正想要的,我想。例如,假設我們有兩個時間序列Q,C:如何更改R包中的每步加權係數DTW

Q = array(c(0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0),dim=c(8,2)) 
C = array(c(0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0),dim=c(8,2)) 

當我計算DTW距離,我得到 對準= DTW(Q,C,保持= TRUE) 隨着2.41 alginment $距離和成本矩陣其中例如[2,2]元素是2而不是1,因爲在對角的重量或2 * d懲罰[I,J]之間進行選擇的最小時:

g[i,j] = min(g[i-1,j-1] + 2 * d[i ,j ] , 
       g[i ,j-1] +  d[i ,j ] , 
       g[i-1,j ] +  d[i ,j ]) 
+0

你應該提供一個最小的[可重現的例子](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)樣本數據顯示你正在使用的功能以便更容易地幫助你。 – MrFlick

回答

1
plot(asymmetricP1) 
edit(asymmetricP1) 
structure(c(1, 1, 1, 2, 2, 3, 3, 3, 1, 0, 0, 1, 0, 2, 1, 0, 2, 
1, 0, 1, 0, 1, 0, 0, -1, 0.5, 0.5, -1, 1, -1, 1, 1), .Dim = c(8L, 4L), class = "stepPattern", npat = 3, norm = "N") 

看看情節,並考慮從右至左排列的樹枝(即。下面BRANCH1 = 0.5重量) 一切都在劇本中情節的情況下(asymmetricP1)和編輯(asymmetricP1)

#first 8 digit sequence (1,1,1,2,2,3,3,3.... 
#branch1: "1,1,1" <- amount of intervals assigned to specificaly branch1; (end, joint, origin) 
#branch2: "2,2" <- only 2 intervals, this is the middle diagnol line. 
#branch3: "3,3,3" <- amount of interals 
#note: Don't be confused by the numbers themselves, ie. "4,4,4" <- 3 intervals; "2,2,2" <- 3 intervals 

#for the next sequences consider: 
#the sequence of each branch is to be read as farthest from origin -> 0,0 
#each interval assignment is accounted for in this order 

#next 8 digit sequence: 1, 0, 0, 1, 0, 2, 1, 0, 
#branch1: 1,0,0 <- interval position in relation to the query index 
#branch2: 1,0 <- interval position in relation to the query index 
#branch3: 2,1,0 <- interval position in relation to the query index (again see in plot) 

#next 8 digit sequence: 2, 1, 0, 1, 0, 1, 0, 0 
#branch1: 2,1,0 <- interval position in relation to the REFERENCE index 
#branch2: 1,0 <- interval position in relation to the reference index 
#branch3: 1,0,0 <- interval position in relation to the reference index (again see in plot) 

#next 8 digit sequence: -1, 0.5, 0.5, -1, 1, -1, 1, 1 
#note: "-1" is a signal that indicates weighting values follow 
#note: notice that for each -1 that occurs, there is one value less, for example branch 1 
# .....which has 3 intervals can only contain 2 weights (0.5 and 0.5) 
#branch1: -1,0.5,0.5 <- changing the first 0.5 changes weight of [-1:0] segment (query index) 
#branch2: -1,1 <- weight of middle branch 
#branch3: -1,1,1 <- changing the second 1 changes weight of[-1,0] segment (query index) 

#.Dim=c(8L, 4L): 
#8 represents the number of intervals (1,1,1,2,2,3,3,3) 
#4 (from what I understand) is the (length of all the branch sequences mentioned previously)/8 

#npat = 3 
#3 is the number of patterns you described in the structure. ie(1,1,1,2,2,3,3,3) 

希望這會有所幫助,祝你好運!