-
Notifications
You must be signed in to change notification settings - Fork 408
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
Add convolve for DiscreteNonParametric #1523
Changes from all commits
15ec552
62331ac
735a33f
1c05992
af9bc65
4b27856
f85407a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -66,6 +66,27 @@ using Test | |||||
@test d3 isa Poisson | ||||||
@test d3.λ == 0.5 | ||||||
end | ||||||
|
||||||
@testset "DiscreteNonParametric" begin | ||||||
d1 = DiscreteNonParametric([0,1],[0.5,0.5]) | ||||||
d2 = DiscreteNonParametric([1,2],[0.5,0.5]) | ||||||
d_eps= DiscreteNonParametric([-1* eps(Float64),0.0,eps(Float64),1.0],[1//4,1//4,1//4,1//4]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use
Suggested change
|
||||||
d10= DiscreteNonParametric(collect(1:10)//10,ones(Int,10)//10) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
d_int_simple = @inferred(convolve(d1, d2)) | ||||||
@test d_int_simple isa DiscreteNonParametric | ||||||
@test support(d_int_simple) == [1,2,3] | ||||||
@test probs(d_int_simple) == [0.25,0.5,0.25] | ||||||
|
||||||
d_rat = convolve(d10, d10) | ||||||
@test support(d_rat)[1] == 1//5 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this could be made more precise?
Suggested change
|
||||||
@test probs(d_rat)[1] == 1//100 | ||||||
|
||||||
d_float_supp = convolve(d_eps, d_eps) | ||||||
@test support(d_float_supp)[3] == 0.0 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be
Suggested change
since numerically |
||||||
@test probs(d_float_supp)[3] == 3//16 | ||||||
end | ||||||
|
||||||
end | ||||||
|
||||||
@testset "continuous univariate" begin | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.