Sha256: bbacfa9c34a019fab7184a0ffe6b79a29e512b1702bf5463cca719df560774da
Contents?: true
Size: 675 Bytes
Versions: 5
Compression:
Stored size: 675 Bytes
Contents
#!/usr/bin/env ruby # -*- encoding: utf-8 -*- # Copyright Steffi Dorn <mail@muflax.com>, 2018 # License: GNU APGLv3 (or later) <http://www.gnu.org/copyleft/gpl.html> module Math class << self def harmonic n (1..n).reduce(0.0){|s, i| s + (1.0 / i)} end def zipf k, n 1.0 / (k.to_f * harmonic(n)) end def tolerance total θ = total / Math.log(total) θ > total ? total : θ.round end alias :tolerate :tolerance alias :θ :tolerance # TODO meh iterative solution def sufficiency exceptions n = 1 n += 1 while θ(n) < exceptions n end alias :sufficient :sufficiency end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
muflax-0.3.13 | lib/muflax/math.rb |
muflax-0.3.12 | lib/muflax/math.rb |
muflax-0.3.11 | lib/muflax/math.rb |
muflax-0.3.10 | lib/muflax/math.rb |
muflax-0.3.9 | lib/muflax/math.rb |