You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
559 B
28 lines
559 B
import ascending from "./ascending"; |
|
import number from "./number"; |
|
import quantile from "./quantile"; |
|
|
|
export default function(values, valueof) { |
|
var n = values.length, |
|
i = -1, |
|
value, |
|
numbers = []; |
|
|
|
if (valueof == null) { |
|
while (++i < n) { |
|
if (!isNaN(value = number(values[i]))) { |
|
numbers.push(value); |
|
} |
|
} |
|
} |
|
|
|
else { |
|
while (++i < n) { |
|
if (!isNaN(value = number(valueof(values[i], i, values)))) { |
|
numbers.push(value); |
|
} |
|
} |
|
} |
|
|
|
return quantile(numbers.sort(ascending), 0.5); |
|
}
|
|
|