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 5d78b973 authored by Dahua Lin's avatar Dahua Lin

add probs for DiscreteUniform

parent d62567dc
......@@ -11,6 +11,17 @@ end
DiscreteUniform(b::Integer) = DiscreteUniform(0, b)
DiscreteUniform() = DiscreteUniform(0, 1)
function probs(d::DiscreteUniform)
n = d.b - d.a + 1
fill(1.0 / n, n)
end
function probs(d::DiscreteUniform, rgn::UnitRange)
f, l = rgn[1], rgn[end]
d.a <= f <= l <= d.b || throw(BoundsError())
fill(1.0 / (d.b - d.a + 1), l - f + 1)
end
function cdf(d::DiscreteUniform, k::Real)
k < d.a ? 0. : (k > d.b ? 1. : (ifloor(k) - d.a + 1.0) / (d.b - d.a + 1.0))
end
......
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