## 3 Methods
Peak Activation Loss (\(\mathcal{L}_{\text{peak}}\)): This loss is designed to promote sparsity along the temporal dimension, encouraging sharp, transient peaks, a concept crucial in event detection [49; 50]. We achieve this by maximizing the peak-to-average ratio for each feature channel. The loss is consequently defined as the negative of this ratio:  
\[\mathcal{L}_{\text{peak}}=-\frac{1}{B\cdot d_{\text{event}}}\sum_{i=1}^{B} \sum_{j=1}^{d_{\text{event}}}\frac{\text{max}_{t=1}^{L}\Bigl{|}z_{\text{ event}}^{(i,j,t)}\Bigr{|}}{\Bigl{(}\frac{1}{L}\sum_{t=1}^{L}\Bigl{|}z_{\text{ event}}^{(i,j,t)}\Bigr{|}\Bigr{)}+\epsilon} \tag{10}\]  
where \(\text{max}_{t}(\cdot)\) finds the maximum value along the temporal dimension \(t\). The term \(\epsilon\) in the denominator is a small constant added to ensure numerical stability and prevent division-by-zero errors. In our implementation, \(\epsilon\) is specifically set to \(1\times 10^{-10}\). Training Goal. The goal of CoTD-VAE is to find the best way to minimize the following loss function:  
\[q(z_{\text{trend}}\mid\mathbf{x}) =\mathcal{N}\Big{(}\mu_{\text{trend}}(\mathbf{x}),\,\text{diag} \Big{(}\sigma_{\text{trend}}^{2}(\mathbf{x})\Big{)}\Big{)},\]0 \[q(z_{\text{trend}}\mid\mathbf{x}) =\mathcal{N}\Big{(}\mu_{\text{trend}}(\mathbf{x}),\,\text{diag} \Big{(}\sigma_{\text{trend}}^{2}(\mathbf{x})\Big{)}\Big{)},\]1  
\(\mathcal{L}_{\text{recon}}\) is the reconstruction loss, computed using the mean squared error (MSE). \(\mathcal{L}_{\text{KL}}^{\text{static}}\), \(\mathcal{L}_{\text{KL}}^{\text{trend}}\) and \(\mathcal{L}_{\text{KL}}^{\text{event}}\) are the KL scatter losses for each of the three latent variables. These losses measure the difference between the posterior distributions and the standard normal prior. \(\beta_{\text{static}}\), \(\beta_{\text{trend}}\) and \(\beta_{\text{event}}\) are the weighting parameters for the KL scatter losses. These are designed as learnable parameters in this implementation. \(\lambda_{\text{smooth}}\) and \(\lambda_{\text{sparse}}\) are weight parameters for the temporal constraints. These are also designed as learnable parameters. During the training process, we use numerical stabilization techniques, such as cropping the gradient and loss values, to ensure the stability and convergence of the training. Disentanglement and classification. CoTD-VAE is trained through a two-step process [51]. This process separates representation learning and downstream task prediction. In the first stage, the variational self-encoder part is trained to learn high-quality latent representations. The training objective is to minimize the reconstruction loss, the KL scatter loss, and the temporal constraints. The classification loss is not included. After finishing the training, the encoder can map time series data to three disentangled potential spaces. In the second stage, we freeze the trained encoder parameters and pass the time series data through the trained VAE encoder to obtain the distribution parameters of the three latent variables: static, trend, and event. The statistical features of the three hidden variables are then put together into a long vector. This is used as input to the random forest to train and test the random forest classifier. Assessment methods. We use the mean square error and mean absolute error to assess the ability of the model to reconstruct the original time series, assess the degree of disentanglement and expressiveness of the latent variables through visualization and statistical analysis, and compute prediction accuracy, precision, recall and F1 score.