Added option to compute an average matrix