From 7f196f0502e3dd506b3f72033cfdf20588843d2f Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Fri, 9 Aug 2019 06:22:10 +0200 Subject: percentile --- percentile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 percentile 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 + -- cgit v1.2.3