Method: MoreMath::Functions#erf

Defined in:
lib/more_math/functions.rb

#erf(x) ⇒ Object

Returns an approximate value for the error function’s value for x.



147
148
149
150
151
# File 'lib/more_math/functions.rb', line 147

def erf(x)
  erf_a = MoreMath::Constants::FunctionsConstants::ERF_A
  r = sqrt(1 - exp(-x ** 2 * (4 / Math::PI + erf_a * x ** 2) / (1 + erf_a * x ** 2)))
  x < 0 ? -r : r
end