*2.1. Context Definition*

Because the application contexts are diverse and time varying in real applications, they can hardly be considered in the algorithm design phase. However, they do have observable impacts on the WD

and SC performances. To evaluate the impacts of dynamic contexts on the algorithms' performances, the availability of real-time context knowledge is modeled as variables. In this paper, five context variables are considered, as shown in Table 1.


**Table 1.** Notations and description of context variables.

The knowledge of orientation *IO* and person information *IP* are modeled by binary variables. *IO* indicates whether the sensor orientation is known or not, and *IP* indicates whether the model is personalized (trained and tested on each subject); the sampling rate *S* and window size *W* are modeled as discrete real numbers, with data range shown in the table; the wearing location is also modeled as a discrete variable, with possible values shown in the table. The available "training" and "testing" data were changed according to the different contexts; for example, if we restrict *L* to being Foot, then only data collected at Foot is available.

Then, let **x** = {*x*1, ··· , *xT*} be the accelerator data sequence collected from 1–*T*, **s** = {*s*1, ··· ,*sT*} be the user state ground truth during this period and *nT* be the step number ground truth. With the consideration of application contexts, **f***w*(**x**) is a specific WD algorithm, which outputs the states of whether the user is walking at each time point from 1–*T*. **f***s*(**x**) is a specific step counting algorithm, which outputs the estimated number of steps from 1–*T*. Then, the walk detection error with consideration of context impacts is represented by:

$$\mathbf{e}\_{w,T} = \sum\_{t=1:T} |\mathbf{s}\_t - \mathbf{f}\_w(\mathbf{x}\_\prime I\_{\odot \prime} I\_{P\prime} \mathbf{R}\_\prime \mathcal{W}\_\prime L))|\tag{1}$$

The step counting error is represented by:

$$\mathbf{e}\_{\mathbf{s},T} = \frac{|n\_T - \mathbf{f}\_{\mathbf{s}}\left(\mathbf{x}\_{\mathbf{f}} I\_{\mathbf{O}\prime} I\_{\mathbf{P}\prime} \mathbf{R}\_{\prime} \mathcal{W}\_{\prime} L\right)|}{n\_T} \tag{2}$$

In the following sections, we introduce walk detection and step counting algorithms, i.e., {**f***w*(**x**),**f***s*(**x**)}, and present the performance evaluations of these algorithms for different application contexts.
