## 6 Sensor Data Acquisition and Collection
### Sensor Data Collection by HMM
For example, a \(\xi^{60}\) could have one valid path given by \((\mathbf{z}_{1}^{1},\mathbf{z}_{2}^{1},\mathbf{z}_{3}^{2},\mathbf{z}_{4}^{3},\mathbf{z}_{5}^{2},\ldots,\mathbf{z}_{60}^{1})\) with \(\xi^{60}_{2}=\mathbf{z}_{1}^{1}\) (i.e., state at the time instant 2 is \(S_{1}\)) and \(\xi^{60}_{4}=\mathbf{z}_{4}^{3}\) (i.e., state at the time instant 4 is \(S_{3}\)), while the most likely path \(\xi^{60^{*}}\) is given by \((\mathbf{z}_{1}^{1},\mathbf{z}_{2}^{2},\mathbf{z}_{3}^{2},\mathbf{z}_{4}^{3},\mathbf{z}_{5}^{2},\ldots,\mathbf{z}_{60}^{1})\) with \(\xi^{60^{*}}_{2}=\mathbf{z}_{2}^{2}\) (i.e., state at the time instant 2 is \(S_{2}\)) and \(\xi^{60^{*}}_{4}=\mathbf{z}_{4}^{3}\) (i.e., state at the time instant 4 is \(S_{3}\)). As a result, a trained HMM model characterizes some \(\xi^{T}\) with its parameters \(\Theta\). The training itself follows the concept of MLE (Maximum Likelihood Estimation) through a fitting of the parameters with the data set \(\mathcal{D}\) that has \(M\) samples and \(N\) Latent states:  
\[\begin{split}\textbf{HMM Identification:}&\ \ \Theta_{ Trained(\mathcal{D},N)}=\arg\max_{\theta}\,\ln p(\mathcal{D}|\theta,N)\\ &\ \```
Result:\(\mathcal{N}(n_{k}^{[Comfort]},\sigma_{k}^{[Comfort]}),\Theta_{Trained}\) Input:\(\mathcal{D}_{Comfort}\), K \(N\gets AIC(\mathcal{D}_{Comfort})\) \(\xi^{T^{*}[Comfort]}\leftarrow\Theta_{Trained(\mathcal{D}_{Comfort},N)}(\mathcal{D}_ {Comfort})\) for\(k=1,2,\ldots,K\)do \(\mathcal{N}(\mu_{k}^{[Comfort]},\sigma_{k}^{[Comfort]})\leftarrow\ \xi^{T^{*}[Comfort]}(k)\)  end for Note:\(N\) refers to the number of discretized states for the load conditions; \(k\) is one of the \(K\) number of temporal clusters; \(\mathcal{D}_{comfort}\) is the data set from comfortable socket usage; \(\xi^{T^{*}[Comfort]}\) refers to the \(\xi^{T^{*}}\) that is labeled as _Comfort_. It is derived from the HMM model trained with \(\mathcal{D}_{comfort}\) for the same data set \(\mathcal{D}_{comfort}\); \(\mathcal{N}(\mu_{k}^{[Comfort]},\sigma_{k}^{[Comfort]})\) refers to the \(\mathcal{N}(\mu_{k},\sigma_{k})\) for a \(\xi^{T^{*}[Comfort]}\).
```

**Algorithm 2**Training HMM-based cluster model for the description of reference operation.

Within the mechatronics-twin framework, the trained HMM models constitute the basis for inferring different operational scenarios. That is, when fed with a specific new observation data set \(\mathcal{D}_{Obs}\), labeled as _Obs_, the trained HMM model defines the most likely path of execution progress \(\xi^{T^{*}[Obs]}\):

\[\textbf{HMM Inference:}\ \xi^{T^{*}[Obs]}\leftarrow\Theta_{Trained(\mathcal{D}, \mathcal{N})}(\mathcal{D}_{Obs})\,. \tag{6}\]

As preparation for comparing different operational scenarios, the time series data of inferred operational paths are further grouped according to the phases of gait progress. This means that the \(\xi^{T^{*}}\) of time interval \(T\) is segmented into \(K\) number of time-based soft clusters, referred to as temporal clusters. Such a clustering enables the alignment of similar operational phases in different gait cycles despite the actual lengths of their \(T\). Moreover, each temporal cluster is assigned a unique Gaussian Kernel, shaped by the corresponding execution progress data of \(\xi^{T^{*}}\) that are mapped to the model. Each cluster \(k\) has the following parameters:

\[\textbf{Temporal Cluster:}\ \xi^{T^{*}}(k)\sim\mathcal{N}(\mu_{k},\sigma_{k}) \tag{7}\]

where \(\mu_{k},\sigma_{k}\) represent the Gaussian mean and variance of execution progress data \(\xi^{T^{*}}(k)\), which are the data of \(\xi^{T^{*}}\) mapped to the cluster \(k=\{1,2,\ldots,K\}\); and \(K\) is the total number of such clusters for the time interval \(T\).