Adding missing features of cosine distribution#2017
Adding missing features of cosine distribution#2017jaksle wants to merge 20 commits intoJuliaStats:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2017 +/- ##
==========================================
- Coverage 86.36% 86.34% -0.03%
==========================================
Files 146 146
Lines 8788 8807 +19
==========================================
+ Hits 7590 7604 +14
- Misses 1198 1203 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
devmotion
left a comment
There was a problem hiding this comment.
Can you add tests for the new functionality?
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
|
I cleaned I added testing against some known simple values. Some more are needed or is this enough? My code was based on how the rest of cosine.jl looked like. When I saw your corrections the code above started looking suspicious for me and indeed, I'm also not sure about dependencies, but its' easy to change in any case. |
|
@devmotion Could I ask for checking if now it is okay? I am a little unsure about the tests. Is there an instruction somewhere what is the recommended way to write them in Distributions.jl? |
devmotion
left a comment
There was a problem hiding this comment.
In general, it is unnecessary and usually it is incorrect to precompute any return types.
For testing, IIRC some utilities such as test_mgf or test_affine (?) exists.
|
@devmotion Good to know that such type inference is not useful. I removed the changes related to this. Optionally, maybe something like function pdf(d::Cosine{T}, x::Real) where T<:Real
z = (x - d.μ) / d.σ
y = (1 + cospi(z)) / (2d.σ)
return insupport(d, x) ? y : zero(y)
endcould be considered. I also added application of build-in functions to test affine transformations and cgf. |
This is a very straightforward PR. It adds missing
mgf,cgf,cfand direct affine transformations for theCosinedistribution. There are simple formulas for these, so there is no reason not to include them.One thing which might require attention is if I protect from dividing by 0 correctly.