nl_tokens: end FUNCTION quantile () FUNCTION : filter ( FLG ) Returns a data filter function .
pl_tokens: function filter ( FLG ) { /**
  		* FUNCTION: filter( data )
  		*	Defines the data filter.
  		*
  		* @param {number} data - numeric stream data
  		* @returns {number} filtered data
  		*/ return function filter ( data ) { var qValues , iqr , bounds = new Array ( 4 ) , idx , d , outliers = [ ] ; // Convert a comma delimited string into an array: data = JSON . parse ( '[' + data + ']' ) ; // Sort the data: data = sort ( data ) ; // Compute the quartiles: qValues = quartiles ( data ) ; // Compute the inter-quartile range: iqr = qValues [ 1 ] - qValues [ 0 ] ; // Compute the outlier bounds: bounds [ 0 ] = qValues [ 0 ] - ( 3.0 * iqr ) ; bounds [ 1 ] = qValues [ 0 ] - ( 1.5 * iqr ) ; bounds [ 2 ] = qValues [ 1 ] + ( 1.5 * iqr ) ; bounds [ 3 ] = qValues [ 1 ] + ( 3.0 * iqr ) ; // Find the values less than the mild lower bound but greater than the extreme lower bound: idx = 0 ; d = data [ idx ] [ 1 ] ; while ( d < bounds [ 1 ] ) { if ( d > bounds [ 0 ] ) { outliers . push ( ( FLG ) ? data [ idx ] : d ) ; } idx += 1 ; d = data [ idx ] [ 1 ] ; } // Find the values greater than the mild upper bound but less than the extreme upper bound: idx = data . length - 1 ; d = data [ idx ] [ 1 ] ; while ( d > bounds [ 2 ] ) { if ( d < bounds [ 3 ] ) { outliers . push ( ( FLG ) ? <mask> [ idx ] : d ) ; } idx = idx - 1 ; d = data [ idx ] [ 1 ] ; } // Return the outliers: return outliers ; } ; // end FUNCTION filter() }