functions for timeseries analysis
use matrix; add reference
add acf function
replace loops with mapcat
cleanup