Added averaging functionality to ps-sim.py.