Distributions.jl is there a deterministic distribution?

I’m working with a structure that has a Distribution field. However I would like it to be able to also take a fixed value without the need to make a Union{Distribution,Real} field type. I think the Dirac distribution does that ? But unless I’m mistaken it is not present in the package. Is there an equivalent whose name I’m not aware of ?

I don’t really understand your question but if you’re asking for a fixed sample, all you need to do is set the seed to the same value every time before sampling:

julia> using Random, Distributions

julia> Random.seed!(123) # Setting the seed

There doesn’t seem to be, but it could certainly be added. I would file an issue on the repo.


If I understand your question correctly, I think you can define your own custom distribution type:

import Distributions: ContinuousUnivariateDistribution
import Base: rand

struct Fixed{T<:Real} <: ContinuousUnivariateDistribution

function rand(dist::Fixed)
    return dist.x

dist = Fixed(1.0)


julia> rand(dist)


Yes that’s the sort of behavior I’m looking for. There’s no native equivalent apparently says @StefanKarpinski , that’s what I wanted to know. I’ll ask on the repo if this could be added.