calculate median statistics