Reworking Distributions.jl

I think the parameter space as type parameter can just be left out. I am not saying that the particular distributions should not be parametrised by the types of their parameters, just that the abstract type does not really need this. There is no point on dispatching on “Distribution with Float64 type parameter”, it is not even clear if the type parameters are values (e.g. a location parameter), whole numbers or probabilities (e.g. in a Binomial).

There are two quantities which perhaps would be useful to know statically on the abstract type level: the type of the samples and the type in which probabilities are measured.

Though right now I cannot really anticipate the use of dispatching a generic distribution on the type of probabilities. In any case, if we leave the probability type out, we can still use a trait with fallback probtype(::Any) = Float64 which maps to what we are doing.

The sample type could be part of the abstract type Sampleable, because if you solicit numbers from a random stream it would be good to have a default.

In total

abstract type Sampleable{X} end

should be more than enough and even

abstract type Sampleable end

would be workable by hooking into the the eltype trait which already exists and makes perfect sense as type trait for Sampleables .

2 Likes