lib/danica/function/gauss.rb in danica-2.4.2 vs lib/danica/function/gauss.rb in danica-2.4.3
- old
+ new
@@ -1,36 +1,22 @@
module Danica
- class Function::Gauss < Function.build(:x, average: { latex: '\mu', gnu: :u }, variance_root: { latex: '\sigma', gnu: :v }) { multiplication(elements) }
+ class Function::Gauss < Function.build(:x, average: { latex: '\mu', gnu: :u }, variance_root: { latex: '\sigma', gnu: :v }) { num(1) / denominator * exponential(exp) }
private
- def elements
- [
- division(1, denominator),
- exponential(exp)
- ]
- end
-
def denominator
- variance_root *
- squared_root(
- multiplication(2, PI),
- )
+ variance_root * sqrt(num(2) * PI)
end
def exp
- negative(
- division(
- power(group(
- addition(x, negative(average))
- ), 2),
- multiplication(2, variance)
- )
+ - (
+ ((x - average) ** 2) /
+ (num(2) * variance)
)
end
def variance
- @variance ||= power(variance_root, 2)
+ @variance ||= variance_root ** 2
end
end
end