code for model of mean activity