Skip to content

Numerical instability in student t distribution #165

Description

@FelixNoessler

Hello,

thanks for creating the Distributions.jl package. I used the Student t distribution in a likelihood function and I noticed some numerical instability for large values of the degrees of freedom. I am not sure if this is expected behaviour.

Best,
Felix

using Distributions
using Statistics
using CairoMakie

############# quantile function is numerically unstable for large degrees of freedom
ν = 10.0 .^ LinRange(0, 20, 200)
d = TDist.(ν)
y = quantile.(d, 0.75)
lines(ν, y; axis = (; ylabel = "0.75 quantile",
                      xlabel = "degrees of freedom ν",
                      xscale = log10))

############# likelihood/logpdf is numerically unstable for large degrees of freedom
data = rand.(TDist(100.0), 100)
νs = 10.0 .^ LinRange(0, 20, 200)

lls = Array{Float64}(undef, length(νs))
for (i,ν) in enumerate(νs)
    d = TDist(ν)
    lls[i] = sum(logpdf.(d, data))
end
lines(νs, lls; axis = (; ylabel = "log likelihood",
                      xlabel = "degrees of freedom ν",
                      xscale = log10))

student_t_quantile
student_t_logpdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions