Skip to content

Conversation

@nsajko
Copy link
Contributor

@nsajko nsajko commented Aug 2, 2025

Fixes #100

@nsajko
Copy link
Contributor Author

nsajko commented Aug 2, 2025

Plots of the error in ULPs after this change

logcosh(::Float32):

f32

logcosh(::Float64):

f64

The plotting happens after downsampling (which just takes the maximum value), which itself happens after smoothing (which also just takes the maximum, i.e., a sliding window maximum). Thus the downsampling and smoothing basically just remove the downward spikes of the noise, preserving the maximum error at the region around each point.

Copy link
Collaborator

@tpapp tpapp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

nsajko added 2 commits August 6, 2025 16:04
oscardssmith has been reviewing the `ULPError` code on
JuliaLang/julia#59087

So sync the code with the changes there.
@tpapp tpapp requested a review from devmotion August 8, 2025 06:50
nsajko added 4 commits August 9, 2025 04:42
As suggested by devmotion on PR #99.
Specialization on the callable argument types should happen anyway.
@nsajko
Copy link
Contributor Author

nsajko commented Aug 14, 2025

bump

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.

The PR looks good, I just wonder if we could cover Float16 as well?

@nsajko nsajko changed the title fix accuracy of logcosh(::Union{Float32, Float64}) fix accuracy of logcosh(::Union{Float16, Float32, Float64}) Aug 16, 2025
@tpapp
Copy link
Collaborator

tpapp commented Aug 16, 2025

@nsajko: thanks for adding Float16. As far as I am concerned this is ready merging now.

@tpapp tpapp merged commit b88d17d into JuliaStats:master Aug 17, 2025
4 checks passed
@tpapp tpapp mentioned this pull request Aug 17, 2025
@nsajko nsajko deleted the logcosh_accuracy branch August 17, 2025 18:21
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.

logcosh(x) accuracy vanishes around the zero, at x = 0

3 participants