Module: Distribution::Weibull::Ruby_
- Defined in:
- lib/distribution/weibull/ruby.rb
Class Method Summary collapse
-
.cdf(x, k, lam) ⇒ Object
Returns the integral of the Weibull distribution from [-Inf to x].
- .pdf(x, k, lam) ⇒ Object
-
.quantile(y, k, lam) ⇒ Object
(also: p_value)
Returns the P-value of weibull.
Class Method Details
.cdf(x, k, lam) ⇒ Object
Returns the integral of the Weibull distribution from [-Inf to x]
18 19 20 21 |
# File 'lib/distribution/weibull/ruby.rb', line 18 def cdf(x, k, lam) return 0.0 if x < 0.0 1.0 - Math.exp(-(x.to_f / lam.to_f)**k) end |
.pdf(x, k, lam) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/distribution/weibull/ruby.rb', line 5 def pdf(x, k, lam) if x < 0.0 0.0 else a = (k.to_f / lam.to_f) b = (x.to_f / lam.to_f) c = (k - 1.0) d = Math.exp(-(x.to_f / lam.to_f)**k) (a * b**c) * d end end |
.quantile(y, k, lam) ⇒ Object Also known as: p_value
Returns the P-value of weibull
24 25 26 27 28 |
# File 'lib/distribution/weibull/ruby.rb', line 24 def quantile(y, k, lam) return 1.0 if y > 1.0 return 0.0 if y < 0.0 -lam * (Math.log(1.0 - y))**(1.0 / k) end |