# Constant/degenerate distribution

**URL:** <https://discourse.julialang.org/t/constant-degenerate-distribution/23817>\
**Category:** Statistics\
**Tags:** question\
**Created:** [May 3, 2019, 3:22pm UTC](https://discourse.julialang.org/t/constant-degenerate-distribution/23817 "2019-05-03T15:22:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 3, 2019, 3:22pm UTC](https://discourse.julialang.org/t/constant-degenerate-distribution/23817/1 "2019-05-03T15:22:25Z")

</div>

Does any Julia package define a specific type for a constant/degenerate distribution, ie a given value with probability 1?

I know I can use a `Distributions.Categorical` with just one value, the question is about having a specific type. I need this as a special case, and it can be made very fast.

Just checking before implementing it.

---

<div class="post-metadata">

**Author:** ![halleysfifthinc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/halleysfifthinc/32/206280_2.png) [@halleysfifthinc](https://discourse.julialang.org/u/halleysfifthinc)\
**Post date:** [May 3, 2019, 3:34pm UTC](https://discourse.julialang.org/t/constant-degenerate-distribution/23817/2 "2019-05-03T15:34:01Z")

</div>

I had the same need recently and ended up using `DiscreteUniform(val,val)`, which has been plenty fast for my needs. The only limitation is that it is limited to Integers. I had initially used a `Bernoulli` distribution, which you could multiply by your desired type, but if you need the support of arbitrary types, `Categorical` distribution with one options seems like the best choice. I’m curious how fast it is for you?

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [May 3, 2019, 3:49pm UTC](https://discourse.julialang.org/t/constant-degenerate-distribution/23817/3 "2019-05-03T15:49:43Z")

</div>

Would a 1-tuple work for your use-case?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 3, 2019, 3:50pm UTC](https://discourse.julialang.org/t/constant-degenerate-distribution/23817/4 "2019-05-03T15:50:48Z")

</div>

Yes, it is just what I was looking for. Thanks!
