Added median function to stats.py