Last active
May 27, 2021 21:16
-
-
Save branch14/760d948329b01b3fa4b8a0a34ae45844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gsl' | |
a = [0,1,2,3,4,8] | |
v = GSL::Vector.alloc(a).sort | |
q1 = v.quantile_from_sorted_data(0.25) | |
q3 = v.quantile_from_sorted_data(0.75) | |
iqr = q3 - q1 | |
tw = q3 + iqr * 1.5 | |
bw = q1 - iqr * 1.5 | |
to = a.filter { |x| x > tw } | |
bo = a.filter { |x| x < bw } | |
# - https://www.gnu.org/software/gsl/doc/html/statistics.html#median-and-percentiles | |
# - https://github.com/ampl/gsl/blob/dee1063dd57ec2841981b010eb732901b452c30a/statistics/quantiles_source.c | |
# - https://muse.union.edu/dvorakt/what-drives-the-length-of-whiskers-in-a-box-plot/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment