The ACF is calculated by taking the correlation between a time series and its lagged version over varying time intervals. Mathematically, it is defined as the correlation between the values of the time series at time `t` and `t+k`, where `k` is the lag. The values of the ACF range from -1 to 1, indicating the strength and direction of the relationship.