-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Use julia implementations for pdfs and some cdf-like functions (
- Loading branch information
Showing
9 changed files
with
90 additions
and
278 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,11 +1,22 @@ | ||
# functions related to chi-square distribution | ||
|
||
# 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 | ||
# 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) |
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.