Investigation of hidden structure and the dipole moment distribution in liquid water and ice