## 3 Design and Implementation
### Classification Algorithm
The decision procedure then becomes the following:  
if (Pr_interaction\({}_{axis_{a}}\geq\) Threshold_level[k]){  change k through predefined rule;  if (Pr_interaction\({}_{axis_{b}}\geq\) Threshold_level[k]) {  type_of_interaction = haptic_interaction[k];  break;  } ...  } else... where,  
\(arrayN_{l}=\) set of all normalization data of \(l-\) axis  with size of \(DATA\_SIZE\)  
\(S=\left\{k\in arrayN_{l}\middle|Thr\_low_{k}<k<Thr\_high_{k}\right\}\)  
\(Pr\_interaction_{l}=\frac{|S|}{DATA\_SIZE}\)  
_Threshold_value[k]_: \(k\)-th probability values learned from the 250 trials to branch. _Thr_low[k]_, _Thr_high[k]_: the \(k\)th upper or lower range value of the \(l\) axis in order to decide type_of_pattern or branch. _haptic_pattern[k]_: name of the \(k\)th haptic pattern. The normalized values on all of the five axes were different among the seven haptic gestures shown in Table 1. For example, all the data from the 250 points had a distribution with normalized probability values of \(-90\leq\) N\({}_{\rm z}\leq 90\). The range of normalized probability for each haptic pattern was calculated from the previous phase. The classification algorithm categorizes the seven haptic gestures based on the difference of each signal in the normalized probability distribution range on the five axes from the acceleration sensor. For example, to classify a TO pattern, the initially gathered acceleration data of each axis sequentially go through a moving average and normalization process. After this process, using the resulting N\({}_{\rm z}\) value, a pattern is determined to have either occurred or not. In this process, termed Phase 1, the predefined \(Thr\_low\) and \(Thr\_high\) values are set to \(-90\) and \(90\), respectively (Figure 3a). If this process returns true, the sensor data of each axis are gathered to the DATA_SIZE limit and then classified in Phase 2. In order to classify a TO pattern during the first stage of Phase 2, the \(Pr\_interaction_{z}\) value is set to \(0.4\) in the range of \(Thr\_low_{k}=-70\), \(Thr\_high_{k}=-15\) (Figure 3a). In the second stage of Phase 2, the \(Pr\_interaction_{x}\) value is set to \(0.8\) in the range of \(Thr\_low_{k}=0\), \(Thr\_high_{k}=20\) (Figure 3b). Through this process and using the predefined threshold values, a TO pattern can be classified effectively from a gathered raw data set. ```

**Algorithm 1** Pseudocode of the authentication algorithm: (**a**) Phase 1. Detecting effective gestures; (**b**) Phase 2. Classification of the seven haptic gestures

**Input**: a piece of raw data from each of the five axes of the acceleration sensor

**Output**: TRUE or FALSE. TRUE when an effective gesture has been detected

**Definition of variable in Phase 1:**

_Thr_low_Thr_high_: threshold values in order to search a starting point of haptic gesture

t: the duration for initial data gathering. Default is 5 seconds

HZ: Sampling frequency of the gathered data per sec

While(t*HZ) {

Gather current x, y, z, x-z, and y-z axis data from the sensor;

Calculate moving average of z axis;

Normalize the calculated moving averages and store to N\({}_{\text{z}}\);

if! (Thr_low \(<\) N\({}_{\text{z}}\)\(<\) Thr_high)

Return TRUE;//effective gesturedetected!