JuliaMath / DensityInterface.jl

Interface for mathematical/statistical densities in Julia
Other
12 stars 3 forks source link

Create `logpdf` and `logcdf` stubs? #15

Open ParadaCarleton opened 1 year ago

ParadaCarleton commented 1 year ago

The ASH package wants to add logpdf and logcdf, but adding a dependency on Distributions might be a little bit overboard. Should we add these here, then overload them in Distributions.jl?

(I recognize that this package is for more than just probability densities, but this seems like the best place to put them.)

@devmotion

devmotion commented 1 year ago

I don't think this should be done. DensityInterface defines logdensityof and densityof which can be used for evaluating densities. So IMO there's no need for logpdf or pdf.

Currently also the API of pdf/logpdf assumes that you call it with a Distribution object. And to define that one has to depend on Distributions anyway. So to me it seems you might rather be interested in https://github.com/JuliaStats/Distributions.jl/issues/1139?

oschulz commented 1 year ago

Could ASH just use logdensityof instead of logpdf? Histograms aren't always normalized anyway, so logpdf wouldn't be an ideal choice, semantically.

logcdf is more tricky, we don't have anything in DensityInterface for that. One option here might be to depend on MeasureBase. MeasureBase has recently gained an API to define transports between measures - transport to/from MeasureBase.StdUniform is equivalent to cdf/quantile functionality. Semantically, the result of ash can be seen as a measure and could in principle be a MeasureBase.AbstractMeasure. MeasureBase is more lightweight as a dependency than Distributions.

CC @cscherrer

cscherrer commented 1 year ago

Thanks @oschulz . It's worth noting that while MeasureBase only provides the API for this functionality and implemetations for a "standard" measures". To get transports for Distributions.Distributions, users will need to depend on DistributionMeasures.jl. That package depends on Distributions (not the other way around). So unfortunately with the current setup it wouldn't be enough for users to just load Distributions.

oschulz commented 1 year ago

It's worth noting that while MeasureBase only provides the API for this functionality and implemetations for a "standard" measures"

Yes, but that should be sufficient to define a cdf/quantile equivalent for ASH interpolations, right? DistributionMeasures should not be required as a dependency.

cscherrer commented 1 year ago

Ah, right. Yes, if ASH is to define its own transport methods, MeasureBase should be plenty.