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 6c209dcb authored by Dahua Lin's avatar Dahua Lin

add probs to Hypergeometric

parent 901e39a9
......@@ -26,6 +26,31 @@ support(d::Hypergeometric) = minimum(d):maximum(d)
islowerbounded(d::Hypergeometric) = true
isupperbounded(d::Hypergeometric) = true
function _probs(d::Hypergeometric, f::Int, l::Int)
ns = d.ns
nf = d.nf
n = d.n
r = Array(Float64, l - f + 1)
r[1] = v = pdf(d, f)
b = f - 1
if l > f
for x = f+1:l
c = ((ns - x + 1) / x) * ((n - x + 1) / (nf - n + x))
r[x-b] = (v *= c)
end
end
return r
end
probs(d::Hypergeometric) = _probs(d, minimum(d), maximum(d))
function probs(d::Hypergeometric, rgn::UnitRange)
f, l = rgn[1], rgn[end]
minimum(d) <= f <= l <= maximum(d) || throw(BoundsError())
_probs(d, f, l)
end
# properties
mean(d::Hypergeometric) = d.n * d.ns / (d.ns + d.nf)
......
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