diff options
author | Patrick Simianer <p@simianer.de> | 2019-08-09 06:22:10 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2019-08-09 06:22:10 +0200 |
commit | 7f196f0502e3dd506b3f72033cfdf20588843d2f (patch) | |
tree | 7a4b9bad25cb27099494ff9ba301bafc7b869997 /percentile | |
parent | 43aa6586f5807aeb99d8e08f996707d92e18774e (diff) |
percentile
Diffstat (limited to 'percentile')
-rwxr-xr-x | percentile | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/percentile b/percentile new file mode 100755 index 0000000..ba9ceb0 --- /dev/null +++ b/percentile @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +require 'zipf' + +data = [] +while line = STDIN.gets + data << line.to_f +end + +data.sort! + +k = ARGV[0].to_i + +index = (k / 100.0) * data.size + +if index.to_i == index + puts data[index.to_i-1] +else + puts (data[index.to_i-1] + data[index.to_i]) / 2.0 +end + |