frequency calculation