change cost function
simulation for sz=32
change cost function back to use mean