# Markov Chain Monte Carlo Based Energy Use Behaviors Prediction of Office Occupants
## 3 Proposed Method
### Model Training
#### 3.3.1 Action Model  
(1) Function model selection:  
This study took the desktop computer as an example to introduce the algorithm in detail. First, a fitting function was required to model the posterior probability distribution of the energy use action behaviors (on and off) for the desktop computer. The distribution of the historical state data of the desktop computer was observed. The power-on time period was selected as 6:00-9:00, and the power-off time period was selected as 14:00-17:00. The action time probability distribution is shown in Figure 4.  
As shown in the Figure 4, it can be concluded that users usually powered on and powered off after 7:30 and 15:00, respectively, and the model was created to simulate the transition process of the user between power-on and power-off in the form of a probability. After many experiments, the logistic function was chosen as the posterior probability distribution model of the on-off action. It can be described as:  
\[P(action|t_{i})=\frac{1}{1+e^{\beta t_{i}+\alpha}} \tag{4}\]  
where \(t\) represents the action time. The parameter \(\beta\) affects the direction and steepness of the curve; the parameter \(\alpha\) affects the position. \(\beta\) and \(\alpha\) are the two model parameters that need to be trained in the MCMC process jointly. The logistic function with different parameters is shown in Figure 5.  
The logistic function satisfied the experimental data, because the probability of the power-on and power-off of the desktop computer would gradually change, which could reflect the change of the on-off action model. Figure 4: Action time probability distribution of the desktop computer. (2) MH sampling:  
The procedure of the MH algorithm was randomly sampling from the probability distribution model of the parameters. Each time, the sampling values of the parameters (\(\beta\) and \(\alpha\)) of the function were changed, and the response was observed. The mean value of all sample values was taken to obtain the optimal approximation. First, in order to plot the random values of the parameters \(\beta\) and \(\alpha\), it was necessary to assume the prior distribution of the parameters. In this paper, a 2D Gaussian distribution was selected as the prior distribution of the parameters. The two edge distributions of the 2D Gaussian distribution were all in the form of a univariate Gaussian distribution, and this can be expressed as:  
\[f\left(x\left|\mu,\tau\right.\right)=\sqrt{\frac{\tau}{2\pi}}exp\left(-\frac{ \tau}{2}\left(x-\mu\right)^{2}\right) \tag{5}\]  
where \(\mu\) is the mean of the normal distribution; \(\tau\) is the accuracy; \(f(x)\) is Gaussian distribution function. The accuracy (\(\tau\)) determines the concentration of the distribution; the mean (\(\mu\)) determines the position of the distribution. The higher the accuracy, the more centralized the presentation data and the smaller the change. The mean can be positive or negative, and the precision must be positive. In order to broaden the search area of the acquired \(\beta\) and \(\alpha\) values, choose \(\mu=0\) and \(\tau=0.01\). The parameter space of the prior distribution is shown in Figure 6.  
Figure 5: The logistic function with varying \(\beta\) and \(\alpha\). Figure 6: Parameter search space for the normal priors’ distribution. It can be seen from Figure 6 that not every point in the parameter distribution space could be attempted, but the most fitting model could be created by random sampling from a higher probability region (the red part in Figure 6). In order to make the test results more accurate, a step size as long as possible should be chosen. In this paper, the step size was 5000. The MH algorithm evaluated the random values of \(\beta\) and \(\alpha\) each time. If the MH sampling condition was satisfied, the current values of \(\beta\) and \(\alpha\) would be accepted, and the state was transferred. If not, the values of \(\beta\) and \(\alpha\) were random values of the previous time.