-
Notifications
You must be signed in to change notification settings - Fork 4
compute nanmedian
kgryte edited this page May 12, 2015
·
1 revision
Computes the median of an array
ignoring non-numeric values.
var data = [ 2, null, 4, 2, NaN, 7, 3 ];
var median = compute.nanmedian( data );
// returns 3
If the input array
is already sorted in ascending order, set the sorted
option to true
.
var data = [ 2, null, 2, 3, NaN, 4, 7 ];
var median = compute.nanmedian( data, {
'sorted': true
});
// returns 3
For object arrays
, provide an accessor function
for accessing array
values
var data = [
[1,2],
[2,null],
[3,4],
[4,2],
[5,NaN],
[6,7],
[7,3]
];
function getValue( d ) {
return d[ 1 ];
}
var median = compute.nanmedian( data, {
'accessor': getValue
});
// returns 3
- Utilities
- Array Creation
- Sorting and Reshaping Arrays
- Special Functions
- Arithmetic
- Relational Operations
- Logical Operations
- Trigonometry
- Geometry
- Sets
- Discrete Mathematics
- Linear Algebra
- Statistics