# Modeling and Reasoning of Contexts in Smart Spaces Based on Stochastic Analysis of Sensor Data +
## 3 Design of Context Model
### Context Graph  
The set of contexts \(\boldsymbol{\hat{C}}\) is used to find a current context during the reasoning process. To improve reasoning methods, \(\boldsymbol{\hat{C}}\) needs to be structured into a context graph. We observed that particular pairs of contexts were occurred by a certain causality or time order. Consider two contexts: \"sleeping at night\" and \"having breakfast\". The two contexts should happen in a certain order, that is, \"sleeping at night\", followed by \"having breakfast\". However, the opposite case, which is, \"having breakfast\", followed by \"sleeping at night\", cannot occur. This infers that contexts may be implicitly described by the hidden property of time--night and morning in this example. The time property can define an order between contexts. However, there is an example in which it does not affect pairs of other contexts, for example, the context \"going to bathroom\". It is meaningless to consider the time property or find a specific order because humans may go to the bathroom at any time while they are sleeping or making breakfast. The two cases support an idea, which is that the time property is not used to model an individual context but defines the relationships between contexts. The context graph reflects the relations by using the features of a directed graph, as shown in Figure 2.  
Figure 2 indicates all transitions between contexts and illustrates how contexts are driven. A causal relation can be either determinative or non-determinative. The contexts under a determinative relation have a single possible transition from a predecessor context. In Figure 2, for instance, \(\boldsymbol{C_{1}}\) and \(\boldsymbol{C_{2}}\) have a determinative relation since \(\boldsymbol{C_{1}}\) is followed by \(\boldsymbol{C_{2}}\). In this case, \(\boldsymbol{C_{2}}\) is only one successor context, which comes next. On the other hand, transitions from \(\boldsymbol{C_{2}}\) have three options, that is, \(\boldsymbol{C_{2}}\) followed by \(\boldsymbol{C_{3}}\), \(\boldsymbol{C_{2}}\) followed by \(\boldsymbol{C_{5}}\), and \(\boldsymbol{C_{2}}\) followed by \(\boldsymbol{C_{6}}\). It is not determinative since the predecessor \(\boldsymbol{C_{2}}\) can transition to any possible successor: \(\boldsymbol{C_{3}},\ \boldsymbol{C_{5}},\ \boldsymbol{C_{5}},\ \text{and}\ \boldsymbol{C_{6}}\). These successors are considered as the next possible contexts, which are followed by \(\boldsymbol{C_{2}}\). We generalize this and define the set of the next possible contexts \(\boldsymbol{C_{N}}\), which follow a given context \(\boldsymbol{C_{j}}\) in Equation (5):  
\[\boldsymbol{C_{N}}=\left\{\boldsymbol{C_{1}},\boldsymbol{C_{2}},\ldots, \boldsymbol{C_{\tau}},\ldots,\boldsymbol{C_{\chi}}\right\}, \tag{5}\]where \(\mathbf{C}_{N}\subseteq\hat{\mathbf{C}}\). Note that every \(\mathbf{C}_{j}\) has its own \(\mathbf{C}_{N}\). For example, the \(\mathbf{C}_{N}\) of \(\mathbf{C}_{1}\) is \(\{\mathbf{C}_{2}\}\), and the \(\mathbf{C}_{N}\) of \(\mathbf{C}_{2}\) is \(\{\mathbf{C}_{3},\mathbf{C}_{4},\mathbf{C}_{5}\}\) in Figure 2. The \(\mathbf{C}_{N}\) of contexts under determinative relation is a singleton set with one possible next context.  
In daily living scenarios, context graph \(\mathbf{C}_{G}\) allows for a context sequence to be repeated as a daily routine. Recall the two contexts, \"making breakfast\" and \"sleeping at night\". The context \"making breakfast\" literally happens every morning, while the context \"sleeping at night\" generally starts every night. The contexts can be repeated daily, as they are cycled. However, the allowance of cycled contexts in \(\mathbf{C}_{G}\) causes an issue, that is, it is difficult to designate a root context, which may be naturally and originally defined. Even though \(\mathbf{C}_{1}\) looks like a root in Figure 2, it might be a next context, which follows a certain context in the real world.