Skip to content
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

Use twoπ and convert it #258

Closed
wants to merge 6 commits into from
Closed

Use twoπ and convert it #258

wants to merge 6 commits into from

Conversation

prbzrg
Copy link

@prbzrg prbzrg commented Sep 24, 2023

Fixes #156

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

Two suggestions:

  • Can you remove the Tau dependency and just use twoπ which is already available via StatsFuns (and IrrationalConstants)?
  • Can you remove the eltype definitions? They are not supposed to denote the parameter types and likely to be changed/clarified in Distributions, sp it's safer to not implememt them for now (and they are not needed for the fix)?

@prbzrg
Copy link
Author

prbzrg commented Sep 24, 2023

I used IrrationalConstants.twoπ and removed eltype definitions.

@prbzrg prbzrg changed the title Use τ and convert it Use twoπ and convert it Sep 24, 2023
end

function Distributions._logpdf(d::TuringDiagMvNormal, x::AbstractVector)
return -(length(x) * log(2π) + 2 * sum(log.(d.σ)) + sum(abs2.((x .- d.m) ./ d.σ))) / 2
s = sum(log, d.σ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sum(log....) to sum(log, ...)) which in the past caused sometimes problems with AD. Better not include such changes.

@devmotion
Copy link
Member

Closed in favour of #259 to avoid unrelated changes.

@devmotion devmotion closed this Sep 24, 2023
@devmotion
Copy link
Member

Thank you for the PR but I think it's better to keep it as minimal as possible 🙂

@prbzrg
Copy link
Author

prbzrg commented Sep 24, 2023

OK, thanks for reviewing.
If there is anything I can do to help, I would like to participate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwanted type promotion from Float32 to Float64 while calculating logpdf of TuringDiagMvNormal
2 participants