Module: Mathpack::Functions
- Defined in:
- lib/mathpack/functions.rb
Class Method Summary collapse
- .beta(a, b) ⇒ Object
- .dawson_minus(x) ⇒ Object
- .dawson_plus(x) ⇒ Object
- .erf(x) ⇒ Object
- .gamma(t) ⇒ Object
- .heaviside(x) ⇒ Object
Class Method Details
.beta(a, b) ⇒ Object
11 12 13 |
# File 'lib/mathpack/functions.rb', line 11 def self.beta(a, b) gamma(a) * gamma(b) / gamma(a + b) end |
.dawson_minus(x) ⇒ Object
19 20 21 |
# File 'lib/mathpack/functions.rb', line 19 def self.dawson_minus(x) Math.exp(x**2) * Mathpack::Integration.integrate(from: 0.0, to: x) { |x| Math.exp(-x**2) } end |
.dawson_plus(x) ⇒ Object
15 16 17 |
# File 'lib/mathpack/functions.rb', line 15 def self.dawson_plus(x) Math.exp(-x**2) * Mathpack::Integration.integrate(from: 0.0, to: x) { |x| Math.exp(x**2) } end |
.erf(x) ⇒ Object
7 8 9 |
# File 'lib/mathpack/functions.rb', line 7 def self.erf(x) 1.0 / (2.0 * Math::PI)**0.5 * Mathpack::Integration.integrate(from: -Float::INFINITY, to: x) { |u| Math.exp(-u**2 / 2.0) } end |
.gamma(t) ⇒ Object
3 4 5 |
# File 'lib/mathpack/functions.rb', line 3 def self.gamma(t) Mathpack::Integration.integrate(from: 0.0, to: Float::INFINITY) { |x| x**(t-1) * Math.exp(-x) } end |
.heaviside(x) ⇒ Object
23 24 25 |
# File 'lib/mathpack/functions.rb', line 23 def self.heaviside(x) x <= 0.0 ? 0 : 1 end |