Add function to compute averge stats, apply in Te demo.