-
Notifications
You must be signed in to change notification settings - Fork 19
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
Abc rejection looks to be slow #12
Comments
It's because you're using an array of distributions. That's not type-stable. If you instead made the priors a tuple of distributions then it would have the right type information. However, you have to go a little further than that as well. Since update_newparams!(newparams,p::Prior) = update_newparams!(newparams,1,p.distributions...)
@inline function update_newparams!(newparams,i,x,y...)
newparams[i] = rand(x)
update_newparams!(newparams,i,y...)
end
@inline function update_newparams!(newparams,i,x)
newparams[i] = rand(x)
end should be it. That's thus infer everything when the number of prior distributions is |
@ChrisRackauckas great, thanks for the tip and the nice proposed solution |
Needed to add i+1 to the above code to implement the recursion So code is: update_newparams!(newparams,p::Prior) = update_newparams!(newparams, 1, p.distribution...)
@inline function update_newparams!(newparams, i, x, y...)
newparams[i] = rand(x)
update_newparams!(newparams, i + 1, y...)
end
@inline function update_newparams!(newparams,i,x)
newparams[i] = rand(x)
end |
this results in about a 10-20% speed up |
should do something similar for calculating prior prob. |
Lots of time spent in getproposal function?
The text was updated successfully, but these errors were encountered: