calculate frequency