Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 18885331 authored by Dahua Lin's avatar Dahua Lin

add scale and rate function to extract scale and rate parameters

parent e482947c
......@@ -103,6 +103,8 @@ export # types
logpmf, # log probability mass
logpmf!, # evaluate log pmf to provided storage
posterior, # Bayesian updating
scale, # scale parameter of a distribution
rate, # rate parameter of a distribution
sqmahal, # squared Mahalanobis distance to Gaussian center
sqmahal!, # inplace evaluation of sqmahal
mean, # mean of distribution
......@@ -126,7 +128,7 @@ export # types
var, # variance of distribution
wsample # weighted sampling from a source array
import Base.mean, Base.median, Base.quantile, Base.max, Base.min
import Base.mean, Base.median, Base.quantile, Base.max, Base.min, Base.scale
import Base.rand, Base.rand!, Base.std, Base.var, Base.cor, Base.cov
import Base.show, Base.sprand
import NumericExtensions.dim, NumericExtensions.entropy
......
......@@ -8,6 +8,9 @@ end
Exponential() = Exponential(1.0)
scale(d::Exponential) = d.scale
rate(d::Exponential) = 1.0 / d.scale
cdf(d::Exponential, q::Real) = q <= zero(q) ? 0.0 : -expm1(-q / d.scale)
function logcdf(d::Exponential, q::Real)
......
......@@ -11,6 +11,9 @@ end
Gamma(sh::Real) = Gamma(sh, 1.0)
Gamma() = Gamma(1.0, 1.0) # Standard exponential distribution
scale(d::Gamma) = d.scale
rate(d::Gamma) = 1.0 / d.scale
@_jl_dist_2p Gamma gamma
function entropy(d::Gamma)
......
......@@ -16,6 +16,9 @@ immutable InvertedGamma <: ContinuousUnivariateDistribution
end
end
scale(d::InvertedGamma) = d.scale
rate(d::InvertedGamma) = 1.0 / d.scale
insupport(::InvertedGamma, x::Real) = zero(x) <= x < Inf
insupport(::Type{InvertedGamma}, x::Real) = zero(x) <= x < Inf
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment