-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Argument order #5
Comments
Thank you for your feedback and suggestion! I really appreciate you taking the time to review the package and provide constructive input. You raise a great point about the argument order. I agree that following the convention of After considering your proposal of |
Yeah, totally, it may make sense for the form to go first. Maybe I don't fully understand the interface, but isn't |
Because for example, we have a structure mean(ClosedWilliamsProduct(), log, Exponetial(10)) which will give the user the value of |
Hmm, I see... Also, looking at the tests – what does |
Yes, it just a convention that should be then clarified somewhere. But what I mean by that is the composition of a |
So yes Indeed you would not be able to evaluate it as a function, but we are still able to use the result from |
Didn't really expect such a twist :) |
I think you are making a good point; however, I want to have a bit of flexibility. My idea boils down to adding an additional import Distributions: Distribution, logpdf
struct Logpdf{D}
dist::D
end
function (f::Logpdf{D})(args...) where {D <: Distribution}
return logpdf(f.dist, args...)
end And the expectation interface will look like this mean(ClosedFormExpectation(), Logpdf(LogNormal(1, 10)), Exponetial(10)) |
It's fine if for some specific purpose you need this kind of But would still be nice to support julia> using Accessors
julia> f = @o logpdf(Normal(0, 1), _)
(::Base.Fix1{typeof(logpdf), Normal{Float64}}) |
Sure, |
@aplavin you can check the state in https://github.com/biaslab/ClosedFormExpectations.jl/tree/clean-interface. I think the PR resolves the issue. |
Nice package, I can see it growing over time to support more functions/distributions!
I wonder if you considered a different argument order, so that to follow regular Statistics.jl
mean(func, collection)
:use
mean(log, Exponetial(10), ClosedFormExpectation())
instead of the currentmean(ClosedFormExpectation(), Exponetial(10), log)
.This isn't too late to change :)
The text was updated successfully, but these errors were encountered: