def median(freqs):
	"""Median from list of numbers and their frequencies"""

	samples = 0

	for (number, freq) in freqs:
		samples += freq

	samples_median = samples / 2.0

	current_samples = 0
	for (number, freq) in freqs:
		current_samples += freq
		if current_samples >= samples_median:
			return number

	return 0