Sha256: 0af51f2525927a13a53160efbe23bf4f7295f832cf585716bd13e5456dad1581
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'active_support/dependencies/autoload' require 'active_support/deprecation' require 'active_support/core_ext' require 'chartnado/series/wrap' module Chartnado module Series # @api public # @example # series_product(2.0, {0 => 1}) => {0 => 2.0} # series_product({0 => 1}, 2.0) => {0 => 2.0} # # @return [Series/Multiple-Series] def series_product(val, series, precision: 2) Wrap[series].times(val, precision: precision) end # @api public # @example # series_ratio({0 => 1}, 2.0) => {0 => 0.5} # # @return [Series/Multiple-Series] def series_ratio(top_series, bottom_series, multiplier: 1.0, precision: 2) Wrap[top_series]. over(bottom_series, multiplier: multiplier, precision: precision) end # @api public # @example # series_sum({0 => 1}, 2.0) => {0 => 3.0} # series_sum({0 => 1}, {0 => 1}) => {0 => 2} # series_sum({0 => 1}, 2.0, 3.0) => {0 => 6.0} # series_sum(1, 2) => 3 # series_sum() => [] # # @return [Series/Multiple-Series/Scalar] def series_sum(*series, scalar_sum: 0.0) Wrap[series.shift].add(*series, scalar_sum: scalar_sum) end # @api public # @example # median([0,1]) => {0.5} # median([0,1,1,2,2]) => {1} # # @return Value def median(array) sorted = array.sort len = sorted.length (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chartnado-0.1.0 | lib/chartnado/series.rb |