Sha256: cb2f9f24a35d3d644ad85a4d5759dc796b716d3beb32cf4cd9f95acd477e85ab

Contents?: true

Size: 732 Bytes

Versions: 3

Compression:

Stored size: 732 Bytes

Contents

module Danica
  class Function::Gauss < Function
    variables :x, :median, :variance_root
    delegate :to_f, :to_tex, :to_gnu, to: :product

    private

    def product
      @sum ||= Product.new(parcels)
    end

    def parcels
      [
        Division.new(1, denominator),
        Exponential.new(exponential)
      ]
    end

    def denominator
      SquaredRoot.new(
        Product.new(2, PI, variance),
      )
    end

    def exponential
      Negative.new(
        Division.new(
          Power.new(Group.new(
            Sum.new(x, Negative.new(median))
          ), 2),
          Product.new(2, variance)
        )
      )
    end

    def variance
      @variance ||= Power.new(variance_root, 2)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.0.6 spec/support/models/functions/gauss.rb
danica-2.0.5 spec/support/models/functions/gauss.rb
danica-2.0.4 spec/support/models/functions/gauss.rb