Added a median function to stats.py