Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This all depends on your interpretation of <em>what</em> an "outlier" is. A common approach: </p> <ul> <li>High outliers are anything beyond the 3rd quartile + 1.5 * the inter-quartile range (IQR)</li> <li>Low outliers are anything beneath the 1st quartile - 1.5 * IQR</li> </ul> <p>This is also the approach described by <a href="http://mathworld.wolfram.com/Outlier.html" rel="nofollow noreferrer">Wolfram's Mathworld</a>.</p> <p>This is easily wrapped up in a function :) I've tried to write the below clearly; obvious refactoring opportunities do exist. <strong>Note that your given sample contains no outlying values using this common approach</strong>.</p> <pre><code>function filterOutliers(someArray) { // Copy the values, rather than operating on references to existing values var values = someArray.concat(); // Then sort values.sort( function(a, b) { return a - b; }); /* Then find a generous IQR. This is generous because if (values.length / 4) * is not an int, then really you should average the two elements on either * side to find q1. */ var q1 = values[Math.floor((values.length / 4))]; // Likewise for q3. var q3 = values[Math.ceil((values.length * (3 / 4)))]; var iqr = q3 - q1; // Then find min and max values var maxValue = q3 + iqr*1.5; var minValue = q1 - iqr*1.5; // Then filter anything beyond or beneath these values. var filteredValues = values.filter(function(x) { return (x &lt;= maxValue) &amp;&amp; (x &gt;= minValue); }); // Then return return filteredValues; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload