Finished Gibb sampling code