fixed bug in calculating ensamble averaged density matrices