Setting an asymptotically optimal threshold for detecting anomalies in a multivariate gaussian sample with application to time series.