added sample mean calculation and plotting