Sha256: df62f91cbc16fe7fa7bbd55faa7ee53c6aa0bdb306f27a696f8264e1e34d87d3

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

module Danica
  class Function::Gauss < Function.build(:x, average: { latex: '\mu', gnu: :u }, variance_root: { latex: '\sigma', gnu: :v }) { multiplication(elements) }

    private

    def elements
      [
        division(1, denominator),
        exponential(exp)
      ]
    end

    def denominator
      variance_root *
      squared_root(
        multiplication(2, PI),
      )
    end

    def exp
      negative(
        division(
          power(group(
            addition(x, negative(average))
          ), 2),
          multiplication(2, variance)
        )
      )
    end

    def variance
      @variance ||= power(variance_root, 2)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.4.2 lib/danica/function/gauss.rb
danica-2.4.1 lib/danica/function/gauss.rb
danica-2.4.0 lib/danica/function/gauss.rb