Median of the distribution

a + b
μ = -----
2

@return float
169907
public function median(): float
    {
        $a = $this->a;
        $b = $this->b;

        return ($a + $b) / 2;
    }
835234
public function variance()
    {
        if ($this->n === 0) {
            throw new RuntimeException('Variance is not defined for vectors'
            . ' with less than 1 element.');
        }

        $ssd = $this->subtract($this->mean())
            ->square()
            ->sum();

        return $ssd / $this->n;
    }
223364
private function realquickRatio()
    {
        $aLength = count($this->a);
        $bLength = count($this->b);

        return $this->calculateRatio(min($aLength, $bLength), $aLength + $bLength);
    }
900403
public function getRatio()
    {
        $total = $this->score->getValid() +
            $this->score->getPartial() +
            $this->score->getNotValid();

        return $this->score->getValid() == 0 ? 0 : (float) number_format($this->score->getValid()/$total, 2);
    }
982310
public function dist(&$A, &$B)
    {
        if (is_int(key($A)))
            $v1 = array_count_values($A);
        else
            $v1 = &$A;
        if (is_int(key($B)))
            $v2 = array_count_values($B);
        else
            $v2 = &$B;

        $r = array();
        foreach ($v1 as $k=>$v) {
            $r[$k] = $v;
        }
        foreach ($v2 as $k=>$v) {
            if (isset($r[$k]))
                $r[$k] -= $v;
            else
                $r[$k] = $v;
        }

        return sqrt(
            array_sum(
                array_map(
                    function ($x) {
                        return $x*$x;
                    },
                    $r
                )
            )
        );
    }
1356610
public static <T> T median(final T a, final T b, final T c, Comparator<? super T> cmp) {
        cmp = cmp == null ? NATURAL_ORDER : cmp;

        int ab = cmp.compare(a, b);
        int ac = cmp.compare(a, c);
        int bc = 0;

        if ((ab >= 0 && ac <= 0) || (ac >= 0 && ab <= 0)) {
            return a;
        } else if ((((bc = cmp.compare(b, c)) <= 0) && ab <= 0) || (bc >= 0 && ab >= 0)) {
            return b;
        } else {
            return c;
        }
    }
281563
public static float median(final float a, final float b, final float c) {
        int ab = Float.compare(a, b);
        int ac = Float.compare(a, c);
        int bc = 0;

        if ((ab >= 0 && ac <= 0) || (ac >= 0 && ab <= 0)) {
            return a;
        } else if ((((bc = Float.compare(b, c)) <= 0) && ab <= 0) || (bc >= 0 && ab >= 0)) {
            return b;
        } else {
            return c;
        }
    }
649923
def median(lst):
    
    #: http://stackoverflow.com/a/24101534
    sortedLst = sorted(lst)
    lstLen = len(lst)
    index = (lstLen - 1) // 2
    if (lstLen % 2):
        return sortedLst[index]
    else:
        return (sortedLst[index] + sortedLst[index + 1])/2.0
625348
public function getPercent()
	{
		if ($this->duration == 0)
		{
			return -1;
		}
		
		$percent = $this->time / $this->duration * 100 / $this->totalPass;
		
		return round(min(100, $percent + 100 / $this->totalPass * ($this->currentPass - 1)), 2);
	}
1358004
public function average()
    {
        $flat = $this->flatten();

        $avg = array();
        foreach ($flat as $metric => $values) {
            $avg[$metric] = (float) number_format(array_sum($values) / count($values), 2, '.', '');
        }

        return $avg;
    }
1023711
public function getMinValue()
    {
        if ($this->isUnsigned) {
            return 0;
        }

        if (!is_null($value = $this->getMaxValue())) {
            return ($value * -1) - ($this->isDecimal() ? 0 : 1);
        }

        return null;
    }
504106
public function maxNorm(): float
    {
        return array_reduce($this->toArray(), function (float $carry, float $value) {
            $value = abs($value);

            return $carry > $value ? $carry : $value;
        }, -INF);
    }
384521
public function normF()
    {
        $f = 0;
        for ($i = 0; $i < $this->m; $i++) {
            for ($j = 0; $j < $this->n; $j++) {
                $f = hypo($f, $this->A[$i][$j]);
            }
        }
        return $f;
    }
829318
public function length2() : float {
        $value = 0;
        $count = count($this->elements);
        for ($i=0;$i<$count;$i++) {
            $value += ($this[$i] * $this[$i]);
        }
        return $value;
    }
802737
public function dist(&$A, &$B)
    {
        $h1 = $this->simhash($A);
        $h2 = $this->simhash($B);
        $d = 0;
        for ($i=0;$i<$this->length;$i++) {
            if ($h1[$i]!=$h2[$i])
                $d++;
        }

        return $d;
    }
539595
public static function IMSUM() {
		// Return value
		$returnValue = self::_parseComplex('0');
		$activeSuffix = '';

		// Loop through the arguments
		$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
		foreach ($aArgs as $arg) {
			$parsedComplex = self::_parseComplex($arg);

			if ($activeSuffix == '') {
				$activeSuffix = $parsedComplex['suffix'];
			} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
				return PHPExcel_Calculation_Functions::VALUE();
			}

			$returnValue['real'] += $parsedComplex['real'];
			$returnValue['imaginary'] += $parsedComplex['imaginary'];
		}

		if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
		return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
	}
831925
public static int Median( int[] values ){
        int total = 0, n = values.length;

        // for all values
        for ( int i = 0; i < n; i++ )
        {
            // accumalate total
            total += values[i];
        }

        int halfTotal = total / 2;
        int median = 0, v = 0;

        // find median value
        for ( ; median < n; median++ )
        {
            v += values[median];
            if ( v >= halfTotal )
                break;
        }

        return median;
    }