Improving environment detection by behavior association for context-adaptive navigation

Navigation and positioning systems depend on both the operating environment and the behavior of the host vehicle or user. The environment determines the type and quality of radio signals available for positioning, and the behavior can contribute additional information to the navigation solution. In order to operate across different contexts, a context-adaptive navigation solu-tion is required to detect the operating contexts and adopt different positioning techniques accordingly. This paper focuses on determining both environments and behaviors from smartphone sensors, serving for a context-adaptive navigation system. Behavioral contexts cover both human activities and vehicle motions. The performance of behavior recognition in this paper is improved by feature selection and a connectivity-dependent filter. Environmental contexts are detected from global navigation satellite system (GNSS) measurements. They are detected by using a probabilistic support vector machine, followed by a hidden Markov model for time-domain filtering. The paper further investigates how behaviors can assist within the processes of environment detection. Finally, the proposed context-determination algorithms are tested in a series of multicontext scenarios, showing that the proposed context association mechanism can effectively improve the accuracy of environment detection to more than 95% for pedestrian and more than 90% for vehicle.

tion system.Behavioral contexts cover both human activities and vehicle motions.The performance of behavior recognition in this paper is improved by feature selection and a connectivity-dependent filter.Environmental contexts are detected from global navigation satellite system (GNSS) measurements.They are detected by using a probabilistic support vector machine, followed by a hidden Markov model for time-domain filtering.The paper further investigates how behaviors can assist within the processes of environment detection.Finally, the proposed context-determination algorithms are tested in a series of multicontext scenarios, showing that the proposed context association mechanism can effectively improve the accuracy of environment detection to more than 95% for pedestrian and more than 90% for vehicle.

| INTRODUCTION
Navigation and positioning are inherently dependent on the context, which comprises both the operating environment and the behavior of the host vehicle or user. 1 Nowadays, many navigation systems are required to operate in different contexts.For our smartphones, their contexts may change from indoor to outdoor environments and can be stationary, on a pedestrian, or on any type of vehicles.To deliver better positioning services, the consideration of context is essential for a navigation system.Although many techniques have been developed or improved for greater navigation accuracy and reliability, their operating scenarios are subject to limited contexts.Examples include multiple-constellation global navigation satellite systems (GNSSs), 2,3 indoor Wi-Fi fingerprinting, 4,5 3D-mapping aided (3DMA) GNSS, [6][7][8] and pedestrian dead reckoning (PDR) using step detection. 9To make full use of these techniques in practical applications, it is necessary to integrate them and then implement the most suitable ones on the basis of context.In order to meet the demand of providing more accurate and reliable positioning services across a wide range of contexts, a multisensor integrated navigation solution is therefore required, that is able to detect the operating context and configure the positioning system accordingly.This is also referred to as context-adaptive navigation. 1,10nvironmental and behavioral contexts respectively reveal where the system is and what the user is doing under particular circumstances.On one hand, the environment determines the type and quality of available radio signals for navigation.For example, most radio signals do not propagate at all in an underwater environment.GNSS reception is good in open-sky environments but poor indoors and in deep urban areas; therefore, the corresponding processing techniques also vary.Wi-Fi and Bluetooth signals are not available in rural areas, in the air, or at sea.Visual positioning performs best in the environments with lots of features.On the other hand, the behavior can contribute additional information to the navigation solution.A stationary pedestrian or land vehicle indicates a fixed location and will not need to update its velocity and position.Trains normally remain on the track, effectively constraining the possible positioning solutions.The requirements of navigation (eg, accuracy, availability, and update rate) can also vary with behaviors.
Context determination is the basis of context-adaptive navigation.Previous work on context detection focused on improving individual subsystems.9][20] Environment detection focused on differentiating between indoor and outdoor environments.Using the "IODetector" proposed by Zhou et al, 21 indoor/outdoor environment is determined by using a combination of cellular signals, light sensors, magnetometers, and proximity sensors.With the same sensor combinations, semisupervised learning 22 and sequential models 23 have been further considered to improve the classification accuracy.In addition, a further outdoor environment framework for urban and open-sky area detection has been proposed by using fuzzy inference in Gao and Groves. 24lthough behavioral and environmental contexts can be detected separately, they are not completely independent in reality. 1 For example, a car typically travels on the road, not in the air or at the bottom of the sea.Previous research focused on improving behavior recognition with environmental context.For example, human behavior was analyzed in Banos et al 25 by integrating location and emotion context.Lu and Fu 26 presented a location-aware activity recognition approach utilizing a Bayesian network, suggesting the accuracy of activity recognition can be improved with environmental features.A location-motion-context (LoMoCo) model was proposed in Pei et al, 27 which uses Bayes reasoning to infer human behavior by estimating the probability of motion patterns occurring at the locations.A similar framework was presented in Liu et al 28 under hidden Markov models (HMMs), where the pedestrian location and motion states are used in a reciprocal manner to improve their estimation of one another.An upgraded version of the model was further described in Chen et al 29 by introducing multiple aspects of context for inferring human activities.
Preliminary environmental and behavioral context detection research has been presented in Gao and Groves, 30 laying the foundation of context detection.Building upon the previous work, this paper contributes to context determination from two aspects.First, a context-determination framework is proposed, within which both behavioral and environmental contexts can be detected, filtered, and associated for a reliable context determination.Second, distinct from other research using environment information for better behavior classification performances, this paper shows how environment detection can be improved with the aid of behavior recognition, since the environment can provide more indication of the signals and positioning techniques applicable for context-adaptive navigation.With the environment detected more accurately, the optimum set of techniques can be selected on the basis of the environments, giving better positioning accuracy and continuity.A smartphone may use PDR or Wi-Fi positioning when carried by the user indoors, switch to GNSS in the outdoor environment, and further apply road map matching when inside a vehicle.Note that the experimental work considers only public transport, not private cars, for practical reasons.
The rest of the paper is structured as follows.The framework and processes of context determination for an adaptive navigation system are first described.Then, behavior recognition, including behavioral feature selection and time-domain filter, is presented.The behaviors to determine in this paper cover different pedestrian activities (eg, static, walking, and running) and different vehicle motions (eg, stationary vehicles, moving buses and moving trains).Next, the method of environment detection, including classification and smoothing, is proposed to determine whether the use is in the indoor, intermediate, or outdoor environment.On the basis of the behavior and environment detection, the authors further investigate how to improve the reliability of environment determination by making use of behavior information.The performances of different context detection algorithms under various scenarios are then presented and compared.Finally, the conclusions and contributions of the paper are outlined.FRAMEWORK Figure 1 presents the overall framework of the contextdetermination algorithm.First, both time-domain and frequency-domain features are extracted from the smartphone sensor measurements.Behavior features are extracted from accelerometers, gyroscopes, magnetometers, and the barometer on the smartphone while environments will be detected on the basis of GNSS signals.
The classification models are constructed from the training datasets and can distinguish the corresponding context categories for the test input features.The outputs of the classification models shall be estimated as probabilities, so that the following context-determination processes and navigation system can adopt different strategies according to the certainty of the results.Then, both behavior and environment classification results from the models are filtered by the proposed behavioral connectivity method and HMM respectively, aiming to minimize incorrect context determination by considering the time-domain relationship between successive epochs.To further enhance the context-determination reliability, behavior and environment association will be considered within the algorithm.Shown as dashed lines in Figure 1, context associations include applying different features and classification models on the basis of the subject of the behaviors and adjusting the parameters of the HMM using the probabilities of the behaviors.Finally, the results of context determination can be used to select suitable sensors, filter frameworks, positioning algorithms, or subsystems for better navigation performance.

| BEHAVIORAL CONTEXT RECOGNITION
A two-step process is implemented for behavioral context recognition: pattern recognition and connectivity.The pattern recognition part covers the processes of extracting the behavioral features from sensor measurements and applying the constructed (behavioral) classification model into distinguishing different behaviors, while the connectivity refers to the following behavioral connectivity block in Figure 1.Pattern recognition algorithms are used to assess the probabilities of the behavior belonging to each category, and then the connectivity mechanism further improves the accuracy of recognition by estimating the relationship of behavior categories between successive epochs.
An implementation of pattern recognition algorithms for behavior recognition has been described in detail in Gao and Groves. 30In the paper, a hierarchical framework was proposed to distinguish both pedestrian activities and vehicle motions.This is shown in Figure 2. Different supervised machine learning algorithms were applied for classification using the features extracted from accelerometers, gyroscopes, magnetometers, and the barometer across a 4-second window length.The 4-second window length is selected as a trade-off between classification accuracy and response latency, which has been justified in Gao. 31 In practice, the window length can be adjusted depending on the behaviors to be determined and specific requirements of real applications.By comparing with different classifiers, it was found that the decision tree (DT) shows better performance for the human-vehicle classifier, while the relevance vector machine (RVM) was selected for the other two classifiers.Further details of these comparisons and an assessment of different window lengths can be found in Gao. 31 This section will further extend the behavior recognition research.First, feature selection algorithms will be applied to find the best combination of features that can perform better classification results.To enhance the recognition reliability, the behavioral connectivity method is further proposed.

| Features selection and classification
In Gao and Groves, 30 different time-domain and frequency-domain features were extracted from sensor measurements.They are summarized in Table 1.Timedomain features describe temporal variations of the motions during the sliding window, including range, variance, skewness, and kurtosis extracted from all sensors.In addition, the zero-crossing rate (ZCR) has also been extracted from the accelerometer signals and is used to differentiate the periods of pedestrian activities changing with the time.Frequency-domain features describe the periodic characteristics of motions during the sliding window.Following a fast Fourier transform (FFT), peaks are centered on different frequency values for different behaviors.For this reason, features in the frequency spectrum can capture significant information on the motion periods of different behaviors and vibration frequencies of different vehicles.Using all of the proposed features, the corresponding classification accuracies of the humanvehicle, human activity, and vehicle motion classifiers were 98.9%, 97.6%, and 91.0%, respectively.
A good set of feature measurements can often provide accurate and comprehensive descriptions of patterns from which the differences between behaviors are easily discerned.However, some of the extracted features may be redundant, introducing noise and irrelevant information.This can cause a deterioration of the classification performance.Feature selection techniques are therefore implemented in order to identify the most relevant features for distinguishing different activities.To explore the best combination of features, the sequential forward floating selection (SFFS) algorithm 32 is applied in this paper.The SFFS algorithm aims to identify the feature subset that minimize the misclassified samples over all feasible feature subsets to obtain better classification performance.
The SFFS procedures are presented in Figure 3.It initializes with an empty set and consists of two main procedures: a new feature is added into the current feature subset if better classification performance is achieved; a conditional exclusion is then applied to the new feature subset, from which the least significant feature is determined.If the least significant feature is the last one added, the algorithm goes back to select a new feature.Otherwise, the least significant feature is excluded and moved back to the available feature subsets and conditional exclusion is continued.This cycle is repeated until there is no further improvement of classification performance.The main advantage of the SFFS algorithm is that the discarded features can be selected again in the inclusion and exclusion procedures.
The SFFS algorithm was implemented for behavioral recognition, by using the same dataset and the same corresponding machine learning algorithms for each classifier described in Gao and Groves. 30Figure 4 shows the average classification accuracy of the three classifiers as a function of the number of features selected by SFFS.The shadow area in the figure indicates the standard deviation using fivefold cross-validation.The results show that the classification performance of each classifier can be slightly improved from 98.9% (20 features, human-vehicle classifier), 97.6% (21 features, human activity classifier), and 91.0%(31 features, vehicle motion classifier), obtained by using all extracted features, to 99.3% (four features), 97.9% (13 features), and 91.5% (27 features), respectively.After feature selection, the corresponding dimensions of features for each classifier are reduced at the same time.

| Connectivity
Behavior connectivity describes the time-domain relationship between the current and previous behavior categories.The direct transitions between some behaviors are more likely than others. 1 The behaviors to determine in this paper cover both pedestrian and vehicle activities.Among them, stationary vehicle behaviors can connect directly to pedestrian behaviors such as sitting or walking.However, pedestrian behavior does not directly connect to moving vehicle behaviors (eg, a moving bus or train) because a vehicle must normally stop to enable a person to get in or out.
Behavioral connectivity is represented in a probabilistic way.Compared with a Boolean approach, there are two advantages.First, a Boolean implementation may occasionally result in the decisions being stuck on incorrect context categories following a faulty selection.This can occur when the correct context category in practice is directly connected to the faulty category determined from the classification algorithm and the other categories are poor matches to the measurement data.Expressing the results in terms of probabilities is a more flexible way to both increase the likelihood of the directly connected categories and minimize the unlikely ones.Second, a probabilistic scheme permits transitions between context categories that are rare, but not impossible.For instance, landing on water directly is possible for amphibious aircraft, but not for most others.
To represent the time-domain relationship in quantity, the likelihoods of direct connections between behaviors are listed in the connectivity matrix in Table 2, where the permitted direct connections in reality are set to 0.9 and the unlikely connections are set to 0.1.The parameters are well tuned to permit direct connection between behaviors and tolerant faulty outputs from machine learning algorithms at the same time.
Figure 5 shows the behavior connectivity algorithm, comprising the following five steps at each epoch.
The filter gain, α, was set to 0.5, indicating equal importance of the measurements at the current epoch and the estimates at previous epoch.
where the superscript † refers to the operation of Moore-Penrose pseudoinverse, 33 which satisfies the relationship defined in Equation ( 3) where matrix I refers to the identity matrix.The calculation procedures were first introduced in Golub and Kahan. 34 3. After obtaining the transfer matrix, it is reestimated using the connectivity matrix C: The notation ∘ in Equation ( 4) denotes element-wise multiplication, satisfying (Ω ∘ C) i,j = Ω i,j C i,j where the subscript i and j refer to the ith row and jth column of the matrix, respectively.4. Then the likelihoods of the behavioral estimates at current epoch x + k are updated by multiplying the previous behavioral probabilities xk−1 by the new transfer matrix: 5. Finally, the probability of each behavior at current epoch xk is obtained by rescaling the likelihoods x + k with the following equation: where xk,i is the probability of behavior i at epoch k.  probabilistic support vector machine (SVM) in contrast to the heuristic approach described in Gao and Groves. 30Then, the SVM outputs will be smoothed by an HMM to improve the accuracy of context determination.

| Categorization
A good environment categorization for navigation is expected to provide an indication of the positioning techniques applicable for determining position in that environment.For most land navigation applications, locating whether the user is indoor or outdoor is a prerequisite task because indoor and outdoor positionings depends on inherently distinct techniques.In an outdoor environment, GNSS or enhanced GNSS techniques perform well while Wi-Fi positioning or Bluetooth positioning are better options when staying inside a building.In reality, some connection areas between indoor and outdoor environments exist, rendering such scenarios hard to be classified as either indoor or outdoor.Thus, the intermediate category, where a client is adjacent to a building or in a partially enclosed environment, is included as one of the categories.In an intermediate environment, indoor positioning techniques (eg, Wi-Fi and Bluetooth) can still work well, while direct LOS GNSS reception can be limited.Note that the occurrence of intermediate scenarios is quite rare for vehicles, so this category is ignored when the subject is identified as a vehicle.Typical examples of each environment category for both pedestrian and vehicle are summarized in Figure 6.
GNSS signals are used for environment detection in this study for two reasons.First, among smartphone sensors, the availability and quality of satellite signals tend to be less affected by factors other than the environment type.For example, Wi-Fi, Bluetooth, and cellular signals strongly rely on the allocation density of the broadcasting station.Their signal strengths also depend on the distance away from the stations, whereas GNSS signal strengths are roughly constant across Earth's surface.Second, the globally distributed properties of GPS and GLONASS ensure that we can infer environments from the availability and strength of GNSS signals anywhere on Earth.The full development of Galileo and Beidou Systems in the future would further enhance the detection performance.The main drawback of GNSS is its relatively high power consumption when being constantly updated.As the research advances, other sensors could be added into the context-determination framework to improve the environment detection using the GNSS module.To show the effectiveness of the proposed features, a set of GNSS measurements was collected on the Pixel I smartphone.The person holding the smartphone kept walking from an outdoor into an indoor environment.The transition happened at about the 30th second.Figure 7 demonstrates the differences in availability and strength of GNSS signals in the indoor and outdoor environments, respectively.The number of satellites received decreased gradually after moving indoors, as more satellite signals were blocked by the building.Concerning the C/N 0 outputs from the selected three satellites, a drop of about 5 dB-Hz was observed when the person was nearing the building, followed by a sharp decrease when they entered.It was also noted that most of the satellite signals indoors were weaker than 20 dB-Hz and more satellites lost track after 80 seconds as the person moved further deeper indoors.

| Features for environment detection
However, on the basis of the findings in Radu et al 22 and Gao and Groves, 30 these two features are not sufficient for a reliable indoor/outdoor classification.In particular, it is difficult to distinguish "shallow indoor" and "deep urban" scenarios from each other with only these two features.More environmental features are therefore required.
As investigated in Gao and Groves, 30 the feature comprising the total C/N 0 values summed across the satellite signals above 25 dB-Hz was proven to be more useful rather than the single summed C/N 0 values used alone in indoor/outdoor classification for a pedestrian.Therefore, in addition to the two features described above, it is adopted as a third feature for pedestrian-based environment classification, denoted as sumCNR 25 .The similar feature metric optimized for vehicle context will be discussed in Section 5.2.

| Probabilistic support vector machine
The SVM is a supervised classification algorithm derived from statistical learning theory and kernelbased methods. 35,36The significant property of the SVM is that it does not depend on any prior probabilities and can offer accurate results with small training samples in the nonlinear classification problem.Given the training samples with corresponding target labels (y i ∈{−1, +1}), the SVM can construct a classification hyperplane in high-dimensional feature space that maximizes the margin between two classes and minimizes the error.
Suppose f (t k ) is the output of the SVM that measures the distance between the test sample t k and the hyperplane.Platt 37 proposed an approach to obtain the classification probability by fitting the SVM output with a sigmoid function: In this equation, y k is the predictive label of t k .The scalar parameters A and B of Equation ( 7) are learned using maximum likelihood estimation from the training data and their corresponding target values.It is worth noting that the training set can be but does not have to be the same set as used for training the SVM. 38undamentally, the SVM is a binary classifier.This is sufficient to classify two vehicle environment categories (indoor and outdoor).To extend the method for pedestrian environment classification situations with three environment categories, three binary classifiers can be trained.Each SVM classifier will output a pair of probabilities to distinguish every two of the three environment categories.For multiclass application, the probability of each category can be obtained by taking account of all pairs of probabilities.Using Platt's method for each SVM, these pairwise probabilities are combined into posterior probabilities by adopting the method proposed in Price et al 39 as where S i (i = 1, … , L) denotes the ith environment context in this research and there are L = 3 environmental contexts for pedestrian cases.

| Hidden Markov model
An HMM is a time-sequential pattern recognition algorithm, which assumes a Markov process 40 with the states (indoor, intermediate, or outdoor environment) in this study.A first-order Markov process predicts the future states of a process relying only on the present state, not on the sequence of events that preceded it, so it is capable of modeling the process of a device moving from one environment to another according to observations.Within an HMM, the probabilities that the system is in each of the states are estimated, so that the navigation system knows the certainty of the decision.Figure 8 is an illustration of a first-order HMM, where Z k refers to the environments to determine at epoch k and t k is the test sample that is also called observation in the context of HMM.Given the sequence of the observations, the most likely sequence of the contexts can be inferred using the Viterbi algorithm, 36,40 from which the probabilities of each context at each epoch are estimated.
To construct an HMM, the essential parameters of the model are determined as follows.
The initial state probability distribution defines the probabilities of the states being at the first epoch.Clearly, the indoor and outdoor contexts occur much more frequently than the intermediate context.As there is no prior information about the initial state, when there is insufficient information to correctly determine the context, it is better to select the intermediate context than to incorrectly select the indoor or outdoor context.The initial probabilities were therefore set as follows: where S 1 , S 2 , and S 3 denote three hidden states indoor, intermediate, and outdoor, respectively.Each element of the state transition probabilities matrix A defines the probability that a state S i at the immediately prior epoch transits to another state S j at the current epoch.Since the sample interval here is 1 second, when a user was previously indoors, the current state is highly likely to be indoor and might be intermediate, but is not likely to be outdoor.This is because the user rarely moves directly from indoors to a fully outdoor GNSS reception environment.However, when the user is at the intermediate state, he/she can move directly to either of the other states.On the basis of these assumptions and with reference to the parameters applied in indooroutdoor detection, 21,24 the values of the transition probability were as listed in Table 3.Note that the values are selected in order to obtain an experimental balance between responsiveness to change and vulnerability to noise.
The emission probabilities describe the conditional distributions of getting an observation from different states.In this paper, the emission probabilities are constructed from the SVM probabilistic outputs.Given the test samples t k , the emission probability of the HMM can be transformed from P (S i |t k ) of SVM in Equation ( 8) by using Bayes' rule: where P (S i ) is the prior probability of the class.Their values are set the same as the initial probabilities in Equation ( 9).In the practical implementation, the prior probability can be obtained from the distribution of the scenarios.Although behavioral and environmental contexts are detected separately, they are completely independent. 1Certain environments are associated with certain behaviors.For example, all road vehicles are associated with driving, but only off-road vehicles are associated with off-road driving.A bus typically travels more slowly and stops more in cities than on the highway.The location of a stationary pedestrian will not change until they move.This information can be used to estimate the likelihood of the detected behavior and environment combinations and reduce the chances of the contextdetermination algorithms selecting an incorrect context.In this section, two different approaches to assist the process of environment detection with behavior information will be explored, on the basis of either the static/dynamic status of the behaviors, or whether the smartphone is carried by a pedestrian or inside a vehicle.

| Transition probability of HMM
The transition matrix A 0 given by Table 3 is proposed for general cases without considering the behaviors of the users.In reality, a stationary user will stay in the same environment, making it impossible to transit from one to another.This inspires an update to the transition probability with the probability of conducting static behaviors.The modification of transition matrix based on static behavior recognition results is expressed in Equation (11).
where I is the identity matrix and p stat denotes the detected probability of being stationary for both a pedestrian and vehicle.
The updated transition probabilities are linear combinations of the identity matrix that represents no change in environment and the parameters proposed for general situations, according to the probability of static behaviors.
If the user is stationary (p stat = 1), the transition matrix will be equal to the identity matrix, indicating an unchanged environment; if the user is detected to be moving (p stat = 0), the transition probabilities for general cases will be used in HMM.

| Pedestrian/vehicle association
When a smartphone is put inside a vehicle, the GNSS signals are received by passing through the vehicles' metal shell and windows, which makes the signal strengths different inside a vehicle than on a pedestrian.Figure 9 shows the normalized distributions of GNSS C/N 0 inside a vehicle and on a pedestrian under indoor scenarios.The measurements were both collected at static positions for about 10 minutes on a Google Pixel I smartphone at London Paddington train station.The two collection sites were about 1 m away from each other, so they can be treated as similar indoor scenarios.The pedestrian data were collected about 2 minutes after collecting the vehicle data.
Since the two sets of data were not collected at the same time, the positions of the satellites changed during the short time interval.Thus, the GNSS C/N 0 distributions of all satellites are plotted to show different GNSS reception conditions rather than the C/N 0 values of individual satellites.It can be seen that the average signal strength of the vehicle data is about 5 to 10 dB-Hz weaker than the corresponding pedestrian value as a result of attenuation by the vehicle's shell.Therefore, for environment detection based on the signal strength, different environment classification models should be implemented for vehicles and pedestrians.
We also consider the application of a similar metric for vehicular environment classification.Meanwhile, because of the greater signal attenuation inside vehicles, we revised the sumCNR 25 feature for vehicle contexts by finding suitable C/N 0 cut-off thresholds optimized for vehicles.In order to determine the threshold giving the best classification performance, features with different cut-off thresholds were tested by the vehicle dataset that will be described in Section 6.1.A fivefold cross-validation strategy was applied to train and test the classifier the vehicle dataset.Using this strategy, the dataset is randomly divided into five equally sized folders.Each time, four of them are used as training sets while the remaining one is used as a test set.This procedure is repeated five times to ensure that all of the samples are used equally in testing, while maintaining independence of training and testing data for model learning.
The three input features to the SVM are the total C/ N 0 values summed across the satellite signals above different thresholds, along with the total number of received satellites and total signal strength of the GNSS signals.
The classification performance obtained with different thresholds is shown in Table 4.The feature "total C/N 0 values summed across the satellite signals above 30 dB-Hz" shows better performance than others and is thus selected for vehicle-based environment classification.It is denoted as sumCNR 30 .A summary of the features for both pedestrian and vehicle-based environment classification is presented in Table 5.
The HMM parameters in Section 4.4 are proposed for pedestrian situations with three categories; thus, the corresponding modifications should be made for vehicular environment classification because of the change in the categorization.The corresponding initial and transition probabilities are adjusted for vehicle situations in the following Equation (12) and Table 6, respectively.The initial probabilities are set equal for indoor and outdoor contexts.The transition probabilities in Table 6 are obtained by keeping the same values in Table 3 of indoor or outdoor environment connecting to the same context and the same values of transiting to another context.The emission probabilities of the HMM for vehicle context can still be obtained from the probabilistic classification results of a binary SVM classifier as in Equation (10).

| EXPERIMENT RESULTS AND DISCUSSION
In this section, different application scenarios were used to test the performance of the proposed context detection system.This section first describes the collection of the training dataset on both pedestrians and vehicles.Then the performance of the pedestrian and vehicle experiments under different kinds of scenarios is examined and compared with other methods.The sensor measurements from the smartphone accelerometers, gyroscopes, magnetometers, and barometer are collected for behavior recognition in both pedestrian and vehicle experiments.Smartphone GNSS measurements are collected for constructing the environment dataset and also used for environment detection.It is worth noting that some sensor parameter checks and calibration are required if applying the proposed method on another smartphone.For inertial sensors, magnetometers, and the barometer used in behavior recognition, it is necessary to make sure the sensor ranges are large enough to fully describe the behaviors from the measurements.For example, the largest magnitude of specific force of running is around 20 m/s 2 .Accelerometers with ranges smaller than that value may lead to faulty detection results.There is no need to calibrate the sensors as sliding window and subtraction of mean values have been applied in signal processing, which means the extracted features are not significantly affected by the sensor systematic errors.For environment detection, some calibration may be required, since the extracted environmental features strongly rely on the received signal strengths that might vary with different smartphones produced with different antenna designs and GNSS chips.identifying the threshold values of the features, and obtaining the new model by training the new dataset.An alternative way of building the model from different device can be achieved by mapping the received C/N 0 values to the old ones from the distributions under the same scenarios, which is less complex but not as accurate as the first method.

| Environment training dataset
The environment dataset was collected using a Google Pixel I smartphone running Android GNSS logging applications.Both GPS and GLONASS data were logged at 1 Hz.GNSS measurements, comprising time tags, PRN (pseudorandom number) of the satellites, the C/N 0 measurements, satellite azimuths, and elevations can all be logged in files for processing.
The training dataset consists of both the pedestrian and vehicle data to construct the classification models.The pedestrian part was collected by the data collector holding the smartphone in hand.The others were collected inside the vehicle, putting the smartphone on the seats of the buses or on the table of the trains.Table 7 summarizes the dataset that covers different kinds of scenarios in indoor, intermediate, and outdoor environments.Note that all the pedestrian environmental data were collected statically.

| Pedestrian experiments
To test the environment detection ability under different GNSS reception conditions, the proposed environment detection methods were examined under four different scenarios.Each scenario was conducted for 20 minutes.They are shown in Figure 10.Among two outdoor scenarios, Scenario One is an open-sky park while Scenario Two is a typical traditional European area with narrow streets and buildings packed closely together.It is important to note that all the data collections in this section were conducted in January 2018.Thus, the time between training dataset and the test data was at least longer than half a year, allowing the satellite positions to change significantly.Therefore, all the collected test data are independent of the training dataset.During the data collection, the experimenter was allowed to hold the smartphone and behave as normal within the experimental area, such as walking, running, waiting for traffic, and standing take photos.A GMM-HMM (GMM, Gaussian mixture model) environment detection approach was proposed in Gao and Groves, 24 where emission probabilities were modeled by a mixture of Gaussian distributions on the basis of the fitting database.To access the performance, the classification results of GMM-HMM, SVM alone, and SVM-HMM with and without association (whether adopting the static/nonstatic strategy) are presented and compared in Table 8.
First, comparing SVM alone results with those smoothed by HMM, it can be seen that a substantial improvement in detecting indoor and outdoor environments is achieved.It is more obvious for the second and fourth scenarios in urban and indoor environments, where the classification accuracy was improved from 87.25% to 96.5% and from 81.58% to 100%, respectively.This shows that the consideration of the time-sequential relationships between environments can improve context detection.Second, comparing SVM-HMM classification results with and without association in Table 8 environments improved while the correct detected samples decreased a little in urban areas.This finding suggests that the adjustment of transition probabilities with stationary probability does not always improve the environment detection, depending on the situation.When the estimation of the previous epoch is correct, the adjustment is helpful; otherwise, it is not.Third, for the indoor and outdoor classification tasks, the proposed SVM-HMM method with association mechanisms all perform better than the GMM-HMM approach.This third result implies that using SVM to model the emission probability of HMM is more accurate than fitting from the empirical dataset.
From Table 8, it is also noticed that some contexts are more difficult to distinguish than others.The urban environment in Scenario Two is harder to detect than the open-sky environment in Scenario One, although these two scenarios are both outdoor areas.The classification performances of Scenario Three are poor for all approaches, showing the intermediate context is far more difficult to distinguish than indoor and outdoor contexts.One possible reason is that the awning is made of conventional glass that is transparent to GNSS signals.This means that a high proportion of the samples were misclassified to the outdoor environment.

| Vehicle experiment
To assess and compare the performance of different approaches on a vehicle, a practical test was conducted on a bus.The user holding the smartphone was seated inside the bus.At the time, the sensor measurements for both behavior and environment detection were recorded for postprocessing.The bus traveled along South Colonnade Street in the Canary Wharf district of London and stopped at the bus station under the bridge for about 20 seconds, as shown in Figure 11.This route was designed to incorporate both indoor and outdoor environments, as well as moving and stationary vehicle motions.
The context detection results are shown in Figure 12. Figure 12A shows the behavior recognition results where the effectiveness of connectivity can be identified.Comparing the decisions from the RVM with ground truth, some of the samples were misclassified.However, they were corrected after behavioral connectivity, showing that the proposed connectivity mechanism can improve the performance of behavior recognition.The connectivity mechanism is effective when the unlikely connections appear in the detection results.However, for some behavioral connections, such as from walking to taking the bus, the advantage of connectivity cannot stand out since all behaviors can be connected directly.The selection of a 4-second window length for feature selection resulted in about a 3-second time delay in the behavior recognition, as the extracted features contained the information in the previous 3 seconds.Although a shorter window length gives shorter detection latency, it would incur degraded classification accuracy at the same time.A good choice of window length needs to balance cautiously between accuracy and latency to meet the requirement of the specific navigation system.Investigations on how to obtain an optimum window length are foreseen for future work.
Figure 12B shows the environment detection results.The top figure provides the probabilistic outputs of indoor and outdoor detections of the proposed method, and the bottom lines compare the classification performance of different approaches.In Figure 12B, it can be observed that the behavior-aided SVM determination and SVM-HMM methods are able to recognize most indoor and outdoor contexts on the bus.On the contrary, the GMM-HMM approach failed to detect most outdoor samples especially when the bus traveled into the outdoor environment from indoors.The SVM-HMM method with vehicle features gives slightly better classification accuracy than the one with pedestrian features.This proves that using association to adopt different (vehicle/pedestrian) models in environment detection according to the recognized behavior can improve the performance of environment detection in a vehicle.Meanwhile, it is also observed that the combination of HMM and SVM performs slightly better than the SVM method alone.The optimization of HMM transition probabilities by considering the status of the behaviors may further improve the environment detection accuracy; thus, the SVM-HMM method considering all associations gives the best detection performance among the listed approaches.

| CONCLUSIONS
This paper explores environmental context detection with the aid of behavioral context using smartphone sensors.The purpose of context determination is for contextadaptive navigation that is able to detect the operating contexts and reconfigure the positioning algorithms and subsystems.
The behaviors determined in this paper cover different pedestrian activities and vehicle motions.The existing behavior recognition framework has been improved from two aspects, feature selection and connectivity.Results showed that feature selection can slightly improve the performance of each behavioral subclassifier to 99.3% (four features), 97.9% (13 features), and 91.5% (27 features), achieved with less features.Behavior connectivity describes the possibility of a direct connection between the current and previous behavior categories.By applying behavior connectivity, some faulty decisions from the classification algorithms can be corrected, further improving the reliability of behavior recognition.
Environmental context detection has focused on indoor and outdoor classifications.An environment detection scheme has been developed on the basis of GNSS signals and on estimated probabilities of each context.According to the detected behavioral subject (whether it is carried by a pedestrian or inside a vehicle), different features of the satellite signals have been extracted and trained to construct the SVM classification models.Then an HMM is used to smooth the results by assuming a Markov process for the environments.Context association mechanisms have also been proposed, where the environment detection is improved with the aid of behavior recognition by adopting suitable parameters and classification models within the environment detection process.Finally, pedestrian and vehicle experiments under different scenarios showed that the proposed method is able to distinguish most indoor and outdoor contexts with more than 95% accuracy for pedestrian and more than 90% accuracy for vehicles.

F
I G U R E 4 Feature selection performances for three classifiers [Color figure can be viewed at wileyonlinelibrary.com and www.ion.org]F I G U R E 3 Sequential forward floating selection block diagram 2. The relationship between current and previous behaviors can then be expressed as a transfer matrix Ω k , calculated from the estimated probabilities, x− k and xk−1 : Different kinds of radio signals are inherently environment dependent and may be used for environment classification.This section begins by proposing the categorization of environments and explaining why GNSS signals have been selected for detecting the environments.The extraction of suitable features based on the availability and strength of GNSS signals is then described.Next, the environments are classified by a In an indoor environment, most GNSS signals are attenuated by the structure of the building or received by nonline-of-sight (NLOS) paths, rendering them weaker (or unavailable) indoors compared with intermediate and outdoor environments.Thus, features comprising the total number of satellites received and the total measured carrier-power-to-noise-density ratio (C/N 0 ) summed across all satellites received at each epoch are extracted.F I G U R E 6 Examples of different environment categories [Color figure can be viewed at wileyonlinelibrary.com and www.ion.org]

F I G U R E 7
Number of satellites received (left) and selected C/N 0 values (right) during an indoor-outdoor transition [Color figure can be viewed at wileyonlinelibrary.com and www.ion.org]

F I G U R E 8
Structure of a firstorder hidden Markov model T A B L E 3 Transition probabilities of HMM (

F I G U R E 9
Comparison of vehicle and pedestrian indoor data (both data were collected at London Paddington train station, the vehicle data were collected inside a Heathrow Express train, and the pedestrian data were collected standing close to the train, about 1 m away from the inside point) [Color figure can be viewed at wileyonlinelibrary.com and www.ion.org]

6 TsumCNR 30 T A B L E 6
Therefore, it is essential to check whether the ranges and distribution under the open-sky environments of the new device are similar to the ones used for training.If not, a different classification model should be built by collecting the training dataset under different environments, T A B L E 4 Classification performance with respect to different thresholds A B L E 5 Features for environment classification Pedestrian Vehicle Total number of satellites received Total measured C/N 0 values sumCNR 25 Transition probabilities for vehicle-based HMM ( T A B L E 1 A summary of behavioral features (features selected by SFFS are marked with asterisk) Classification results of pedestrian experiments (1200 samples in total for each scenario) T A B L E 8