Latent variable model for anomaly detection