-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Use julia implementations for pdfs and some cdf-like …
- Loading branch information
Showing
9 changed files
with
278 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
# functions related to chi-square distribution | ||
|
||
# R implementations | ||
# For pdf and logpdf we use the Julia implementation | ||
using .RFunctions: | ||
chisqcdf, | ||
chisqccdf, | ||
chisqlogcdf, | ||
chisqlogccdf, | ||
chisqinvcdf, | ||
chisqinvccdf, | ||
chisqinvlogcdf, | ||
chisqinvlogccdf | ||
|
||
# Julia implementations | ||
# promotion ensures that we do forward e.g. `chisqpdf(::Int, ::Float32)` to | ||
# `gammapdf(::Float32, ::Int, ::Float32)` but not `gammapdf(::Float64, ::Int, ::Float32)` | ||
chisqpdf(k::Real, x::Real) = chisqpdf(promote(k, x)...) | ||
chisqpdf(k::T, x::T) where {T<:Real} = gammapdf(k / 2, 2, x) | ||
|
||
chisqlogpdf(k::Real, x::Real) = chisqlogpdf(promote(k, x)...) | ||
chisqlogpdf(k::T, x::T) where {T<:Real} = gammalogpdf(k / 2, 2, x) | ||
# Just use the Gamma definitions | ||
for f in ("pdf", "logpdf", "cdf", "ccdf", "logcdf", "logccdf", "invcdf", "invccdf", "invlogcdf", "invlogccdf") | ||
_chisqf = Symbol("chisq"*f) | ||
_gammaf = Symbol("gamma"*f) | ||
@eval begin | ||
$(_chisqf)(k::Real, x::Real) = $(_chisqf)(promote(k, x)...) | ||
$(_chisqf)(k::T, x::T) where {T<:Real} = $(_gammaf)(k/2, 2, x) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.