Constant/degenerate distribution

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.

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?

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

1 Like

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

1 Like