Sha256: f01d2942202454a78032e81666eb070308867bbecc1c0b43cb984a262de99e45

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

module Danica
  class Function::Gauss < Function
    variables :x, median: :u, variance_root: { latex: '\theta', gnu: :v }
    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

1 entries across 1 versions & 1 rubygems

Version Path
danica-2.1.0 spec/support/models/functions/gauss.rb