-
Notifications
You must be signed in to change notification settings - Fork 6
Implement Analytic Likelihood for Student's T Distribution #81
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||||||
|
||||||||||
using SpecialFunctions :: logbeta | ||||||||||
using IrrationalConstants :: logπ, | ||||||||||
|
||||||||||
|
||||||||||
""" | ||||||||||
StudentTLikelihood(σ²,ν) | ||||||||||
|
||||||||||
Student's T likelihood with `σ²` scale and ν degrees of freedom . This is to be used if we assume that the | ||||||||||
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
|
||||||||||
uncertainity associated with the data follows a Student's T distribution. | ||||||||||
|
||||||||||
```math | ||||||||||
p(y|f) = \\operatorname{Student}(y | f, σ², ν) | ||||||||||
``` | ||||||||||
""" | ||||||||||
|
||||||||||
struct StudentTLikelihood{T<:Real, Tn :: Real} <: AbstractLikelihood | ||||||||||
σ²::Vector{T} | ||||||||||
ν::Vector{Tn} | ||||||||||
Comment on lines
+18
to
+19
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. We tend to change the implementation to avoid storing everything in Vector (I know it's not true for
Suggested change
|
||||||||||
end | ||||||||||
|
||||||||||
function expected_loglikelihood( ::AnalyticExpectation,lik::StudentTLikelihood,q_f :: AbstractVector{<:Normal}, y :: AbstractVector{<:Real}) | ||||||||||
f_μ = mean.(q_f) | ||||||||||
# Why? | ||||||||||
return sum(-logbeta(0.5,0.5*lik.ν) .- 0.5*logπ .- 0.5*log(lik.ν) .- log(lik.σ²) .- (0.5*(lik.ν+1))*log.(1 .+ ((y .- f_μ).^2 + var.(q_f)) / lik.σ²)) | ||||||||||
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 am not sure that this is correct. The expectation of `log( (y - f)^2) is not available analytically I think |
||||||||||
end | ||||||||||
|
||||||||||
|
||||||||||
default_expectation_method(::StudentTLikelihood) = AnalyticExpectation() |
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.
You only need one
: