JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.12k stars 418 forks source link

Censored needs a special multiplication overload #1500

Open sethaxen opened 2 years ago

sethaxen commented 2 years ago

Because the density at the bounds of Censored are discrete probabilities, they don't transform in the same way as the density between the bounds when the uncensored distribution is continuous. We can fix this with an overload like this:

*(d::Censored, σ::Real) = censored(d.uncensored * σ, d.lower * σ, d.upper * σ)
*(d::LeftCensored, σ::Real) = censored(d.uncensored * σ, d.lower * σ, nothing)
*(d::RightCensored, σ::Real) = censored(d.uncensored * σ, nothing, d.upper * σ)

More generally, this is something to keep in mind when considering other distributions with atomics.

mschauer commented 2 years ago

Connected to #1483, there is a latent need for being able to dispatch on distributions which have merely uncountable support and those which are absolute continuous.

devmotion commented 2 years ago

Indeed. I guess, however, here we would want the definitions suggested by @sethaxen in any case, even if we could dispatch on such traits.

mschauer commented 2 years ago

Exactly, but we would like to exclude the general case from the standard definitions.

sethaxen commented 2 years ago

Connected to #1483, there is a latent need for being able to dispatch on distributions which have merely uncountable support and those which are absolute continuous.

I'm not certain how that would help in this case. Because we need the log(σ) for the continuous mixture component but need to not have it for the discrete components. If we have generic mixtures of discrete and continuous components, where a point can be any or all of the components, then even evaluation at a single pojnt might need the adjustment for some components and not others.