my implementation, basically same as given for vector mean on assginment web page