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 901e39a9 authored by Dahua Lin's avatar Dahua Lin

add probs for Geometric

parent 5d78b973
......@@ -8,6 +8,20 @@ end
Geometric() = Geometric(0.5) # Flips of a fair coin
function probs(d::Geometric, rgn::UnitRange)
f, l = rgn[1], rgn[end]
0 <= f <= l || throw(BoundsError())
p = d.prob
r = Array(Float64, l - f + 1)
pfail = 1.0 - p
r[1] = v = (pfail^f) * p
b = f - 1
for i = f+1:l
r[i - b] = (v *= pfail)
end
return r
end
## Support
insupport(::Geometric, x::Real) = isinteger(x) && x >= zero(x)
insupport(::Type{Geometric}, x::Real) = isinteger(x) && x >= zero(x)
......
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