Skip to contents

Given a `proc` data frame containing anomaly labels and cluster assignments, this function calculates summary statistics for each cluster, including the cluster center time, the number of anomalies, and the inter-cluster lag time. It also computes global statistics such as the estimated anomaly rate per cluster (\(\lambda_a\)) and the cluster rate per second (\(\lambda_c\)).

Usage

stat_anom(proc, last_tcen = NULL)

Arguments

proc

A data frame containing anomaly detection results with at least the columns `anomaly`, `cluster`, and `GPS`.

last_tcen

Optional numeric. The center time of the last cluster from the previous batch (used to compute `t_lag`).

Value

A list with the following elements:

table

A data frame of per-cluster statistics: `cluster`, `t_cen` (cluster center time), `N_anom` (number of anomalies), and `t_lag` (inter-cluster lag).

stats

A list of global statistics: `t_batch` (batch duration in seconds), `N_cl` (number of clusters), `N_anom` (total anomalies), `lambda_a`, and `lambda_c`.

last_tcen

The last computed cluster center time (used for streaming).