-
Notifications
You must be signed in to change notification settings - Fork 414
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
Native pdf, cdf, quantile, and related functions for the Normal distribution #714
Conversation
zval(μ::Real, σ::Real, x::Number) = (x - μ) / σ | ||
|
||
normpdf(z::Real) = exp(-abs2(z)/2) * invsqrt2π |
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.
I don't think we should implement the normX
versions.
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.
So rework without going through the normalization step?
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.
I think we should just define these for the Distributions
API, i.e. this method would simply be pdf(::Normal, z)
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.
It could be useful to have a separate "basic" functions. i.e. normpdf(z)
, but we don't need normpdf(x,mu,sigma)
versions.
similarly, normcdf
, but you don't need normccdf
since this is trivially defined in terms of normcdf
.
#### Evaluation | ||
#### Evaluation (see JuliaStats/Distributions.jl/issues/708) | ||
|
||
xval(μ::Real, σ::Real, z::Number) = μ + σ * z |
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.
are xval
and zval
helper functions? Should these get inlined?
zval(μ::Real, σ::Real, x::Number) = (x - μ) / σ | ||
|
||
normpdf(z::Real) = exp(-abs2(z)/2) * invsqrt2π |
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.
So rework without going through the normalization step?
# Journal of the Royal Statistical Society. Series C (Applied Statistics), Vol. 37, No. 3, pp. 477-484 | ||
# | ||
|
||
function _norminvlogcdf_impl(lp::Float64) |
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.
even if not exported, I would be in favour of adding add docstrings to non-trivial functions
|
||
@_delegate_statsfuns Normal norm μ σ | ||
function _qnorm_ker1(q::Float64) |
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.
same thing here, a docstring would help
5.22649_52788_52854_5610e3) | ||
end | ||
|
||
function _qnorm_ker2(r::Float64) |
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.
same there
@Nosferican updates on this? |
I had forgotten about this. I will try to finish it up next I find a break. Thanks for reminding me. |
ping @Nosferican |
I know I have been lagging, but soon I will have time to go back to this. I am defending in two weeks so probably check with me a bit after that. If anyone else wants to take a go in the meantime, feel free. |
Hi @Nosferican, congrats on the defense :) |
also, there might be some merge to do first, and addressing the comments |
Thanks! Seems like the branch I used for the PR was deleted sometime within the last year... I will close this PR and open a fresh one with the comments addressed. |
Porting the native implementation from StatsFuns to Distributions. See #708