Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/likelihoods/studentt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

using SpecialFunctions :: logbeta
using IrrationalConstants :: logπ,
Comment on lines +2 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only need one :

Suggested change
using SpecialFunctions :: logbeta
using IrrationalConstants :: logπ,
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Student's T likelihood with `σ²` scale and ν degrees of freedom . This is to be used if we assume that the
Student's T likelihood with scale `σ²` and `ν` degrees of freedom. This is to be used if we assume that the

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
Copy link
Member

Choose a reason for hiding this comment

The 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 GaussianLikelihood but it should change).

Suggested change
σ²::Vector{T}
ν::Vector{Tn}
σ²::T
ν::Tn

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.σ²))
Copy link
Member

Choose a reason for hiding this comment

The 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()