Constant/degenerate distribution

question
#1

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.

#2

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?

#3

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

1 Like
#4

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

1 Like