Fixed bug in mean matrix estiamtion