Sha256: 0ff59bcb4166b27c23c7e5777340a1a18cc874fa0e946b5dcb5414dac3d3a0fa
Contents?: true
Size: 256 Bytes
Versions: 9
Compression:
Stored size: 256 Bytes
Contents
module Math # Returns the Cumulative Density Function of this # sample (normalised to a fraction of 1.0). def self.cdf(array, normalised=1.0) s = sum(array).to_f array.sort.inject([0.0]) { |c,d| c << c[-1] + normalised*d.to_f/s } end end
Version data entries
9 entries across 8 versions & 2 rubygems