public static function mad(array $values, ?float $median = null) : float
    {
        $median = $median ?? self::median($values);

        $deviations = [];

        foreach ($values as $value) {
            $deviations[] = abs($value - $median);
        }

        return self::median($deviations);
    }
public static function mad(array $values, ?float $median = null) : float
    {
        $median = $median ?? self::median($values);

        $deviations = [];

        foreach ($values as $value) {
            $deviations[] = abs($value - $median);
        }

        return self::median($deviations);
    }
public static function mad ( array $ values , ? float $ median = null ) : float { $ median = $ median ?? self :: median ( $ values ) ; $ deviations = [ ] ; foreach ( $ values as $ value ) { $ deviations [ ] = abs ( $ value - $ median ) ; } return self :: median ( $ deviations ) ; }
Calculate the median absolute deviation of a set of values given a median.

@param array $values
@param float|null $median
@return float
Calculate the median absolute deviation of a set of values given a median .