script to calculate average noise