29:14 Y.Yin et al. Data sequence:A Data sequence:A2 4上 Time series Fig.11.Working principle of DTW. activities.In the following paragraphs,we will show how to utilize the sensor data to distinguish one activity from another in each level. Body Level:As shown in Section 3.1 and Figure 3,the body level includes motionlessness and body movement (e.g.,walking,jogging).According to Section 4.1.4,we can utilize the variance of linear-acc and gyroscope data,that is,Equations(3)and(4),to distinguish motionlessness and body movement easily.For body movement,we need to verify that the activity really belongs to body movement instead of disturbances or noises,thus we use Dynamic Time Warping(DTW) (Sempena et al.2011)for further activity recognition in body level,as follows. Dynamic time warping(DTW)is used for measuring the similarity between two temporal se- quences,which can vary in speed.For example,the user can walk slow or fast,thus the sensor data of an activity segment can be different.Fortunately,by using DTW,we can calculate an op- timal match between two activity segments.Thus,we can still recognize the activity,although the variation exists in sensor data.In Figure 11,we show the working principle of DTW.The data sequences Al and Az are warped non-linearly in the time dimension,to obtain the optimal match between them.For example,at time to,the data in Ai and A2 are represented as D and F,respec- tively.However,DTW matches D with E(data at time t4 in Az)instead of F.In body movement, we use DTW to measure the similarities between consecutive body movements,as shown in the following steps. -Step 1:Calculating the resultant linear-acc.Considering that people may hold the phone in different ways,the coordinate systems can be different,as shown in Figures 4(b)and 4(c). Thus,we will not compare the sensor data of body movements in each axis.Instead,we use the resultant linear-acc for similarity comparison.For an activity segment,the sam- pling data of linear-acc in x-axis,y-axis,and z-axis are represented as xa,yai,and zai,re- spectively:i N-1].Then,we use to obtain the resultant linear-acc. Figure 12(a)shows the linear-acc in each axis,while Figure 12(b)shows the resultant linear- acc of Figure 12(a). -Step 2:Calculating the DTW distances.As shown Figure 12(b),we can obtain the resultant linear-acc of each activity segment,such as segment i,j,k.Although some difference exists in the segments,we can use DTW to obtain the best match between them.For any two activity segments (e.g.,i and j),we use DTW(Sempena et al.2011)to calculate the dis- tance between them for similarity comparison.Smaller distance means higher similarity.In Figure 12(c).take the segment of "walking"as an example,we calculate the DTW distance between the segment with 10 "walking"activities,10"jogging"activities,respectively.It indicates that the DTW distance between the same type of activities is very small,while ACM Transactions on Sensor Networks,Vol 13.No.4,Article 29.Publication date:September 201729:14 Y. Yin et al. Fig. 11. Working principle of DTW. activities. In the following paragraphs, we will show how to utilize the sensor data to distinguish one activity from another in each level. Body Level: As shown in Section 3.1 and Figure 3, the body level includes motionlessness and body movement (e.g., walking, jogging). According to Section 4.1.4, we can utilize the variance of linear-acc and gyroscope data, that is, Equations (3) and (4), to distinguish motionlessness and body movement easily. For body movement, we need to verify that the activity really belongs to body movement instead of disturbances or noises, thus we use Dynamic Time Warping (DTW) (Sempena et al. 2011) for further activity recognition in body level, as follows. Dynamic time warping (DTW) is used for measuring the similarity between two temporal sequences, which can vary in speed. For example, the user can walk slow or fast, thus the sensor data of an activity segment can be different. Fortunately, by using DTW, we can calculate an optimal match between two activity segments. Thus, we can still recognize the activity, although the variation exists in sensor data. In Figure 11, we show the working principle of DTW. The data sequences A1 and A2 are warped non-linearly in the time dimension, to obtain the optimal match between them. For example, at time t6, the data in A1 and A2 are represented as D and F , respectively. However, DTW matches D with E (data at time t4 in A2) instead of F . In body movement, we use DTW to measure the similarities between consecutive body movements, as shown in the following steps. —Step 1: Calculating the resultant linear-acc. Considering that people may hold the phone in different ways, the coordinate systems can be different, as shown in Figures 4(b) and 4(c). Thus, we will not compare the sensor data of body movements in each axis. Instead, we use the resultant linear-acc for similarity comparison. For an activity segment, the sampling data of linear-acc in x-axis, y-axis, and z-axis are represented as xai , yai , and zai , respectively; i ∈ [0, N − 1]. Then, we use x2 ai + y2 ai + z2 ai to obtain the resultant linear-acc. Figure 12(a) shows the linear-acc in each axis, while Figure 12(b) shows the resultant linearacc of Figure 12(a). —Step 2: Calculating the DTW distances. As shown Figure 12(b), we can obtain the resultant linear-acc of each activity segment, such as segment i, j, k. Although some difference exists in the segments, we can use DTW to obtain the best match between them. For any two activity segments (e.g., i and j), we use DTW (Sempena et al. 2011) to calculate the distance between them for similarity comparison. Smaller distance means higher similarity. In Figure 12(c), take the segment of “walking” as an example, we calculate the DTW distance between the segment with 10 “walking” activities, 10 “jogging” activities, respectively. It indicates that the DTW distance between the same type of activities is very small, while ACM Transactions on Sensor Networks, Vol. 13, No. 4, Article 29. Publication date: September 2017.