# Context-Based Energy Disaggregation in Smart Homes
## 4 Disaggregation Algorithm
### Context-Based Disaggregation
#### 4.3.2 User Presence/Absence Conditioning  
The necessary information to perform this second conditioning derives from presence sensors appropriately deployed in the house. This type of conditioning consists in modifying the probability associated to the \"OFF-ON\" transitions of a device trace, according to the presence/absence of a user in a specific time interval. It was assumed, in fact, for specific types of appliances, the turning-ON event cannot occur without the presence of a user.  
In particular, we considered two possible time intervals of observation:  
* Presence/absence of users in a single time interval;
* Presence/absence of users in two consecutive time intervals.  
Figure 2: Usage statistics distribution for a refrigerator (**a**) and a washing machine (**b**).  
The time interval duration is arbitrarily set as the longest consumption cycle that has been detected among the analyzed traces (_i.e._, a washing machine cycle).  
In order to clarify this critical claim, it is useful to analyze the operating characteristic of a washing machine through a three-state Markov chain: state 1 \"OFF\", state 2 \"WASHING PROGRAM\", state 3 \"WATER HEATING\". In Figure 3, the \(P_{ij}\) terms indicate the transition probability from the state \(j\) to the state \(i\), typical of the single device.  
The example shows that the device in examination does not provide, among the possible transitions, the transition from state 1 to state 3 without passing through state 2 (\(P_{13}\) and \(P_{31}\) are nil). Table 1 shows the probabilities to transit from state \(i\) to state \(j\) and _vice versa_ in a single step.  
User absence in the single time interval implies that:  
* If the device is ON, it will continue its customary working cycle until the end of the washing cycle;
* If the device is OFF, the transition to state 2 is not possible ON during the time interval (because there are not users in its neighborhood), thus: \(P_{21}=0\) as it is shown in Figure 4 and in Table 2.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**j** & **S1** & **S2** & **S3** \\ \hline
**i** & 0.9978 & 0.0022 & 0 \\
**S2** & 0.0307 & 0.9690 & 0.0003 \\
**S3** & 0 & 0.0012 & 0.9988 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Example of a transition matrix for a washing machine.  
Figure 4: Example of a state machine for a washing machine derived by taking into account user presence information.  
Figure 3: Example of a State Machine with associated transition probability modeling a washing machine operation.  
The user absence for two consecutive time intervals, instead, implies that:  
* If the device was ON before the beginning of the observation (before the first interval), it will have terminated its working cycle within the first interval; therefore, it is currently OFF (OFF in the second interval);
* If the device was OFF, it will not have had a new turning-ON, thus it is currently OFF (always in the second interval). The Markov chain for the device in the second time interval collapses in a single state, precisely the OFF state, with, as the sole possible transition, itself; the probability from state 1 to state 1 results thus unitary (\(P_{11}=1\)) as shown in Figure 5 and in Table 3.  
Hereafter, we will refer to these conditioning mechanisms as follows: Usage Statistic Conditioning (USC) and User Presence (UP) single/double Interval Conditioning (IC).