Distributions

Distributions.TDistType
TDist(μ, σ, ν)

Defines the three parameter version of the Student-t distribution.

The distribution is parameterized so that the variance is σ²ν/(ν-2). The distribution is constructed by extending the standard student-t in Distributions.jl using the LocationScale construction in that same package.

Examples

julia> using Statistics: mean;
julia> using Distributions: pdf;
julia> dist = TDist(1, 2, 5)
julia> mean(dist) 
1.0
julia> pdf(dist, 1)
0.18980334491124723
source
Utils.GaussianCopulaType
GaussianCopula(CorrMat, f)

Construct a Gaussian Copula with correlation matrix CorrMat and marginal distributions given by the elements in the vector of distributions in f.

If f is a singleton, then this distribution is used for all margins.

Examples

julia> using PDMats
julia> f = [Normal(2, 3), Normal()]
julia> CorrMat = PDMat([1 -0.8; -0.8 1])
julia> GC = GaussianCopula(CorrMat, f)
source
Utils.PGDistOneParamType
PGDistOneParam(b, nterms)

Polya-gamma distribution with one parameter and nterms in the tructation of the pdf.

Examples

julia> using Distributions: pdf;
julia> d = PGDistOneParam(1, 10)
julia> pdf(d, 1.1)
source
Utils.NormalInverseChisqType
NormalInverseChisq(μ, σ2, κ, ν)

A Normal-χ^-2 distribution is a conjugate prior for a Normal distribution with unknown mean and variance. It has parameters:

  • μ: expected mean
  • σ2 > 0: expected variance
  • κ ≥ 0: mean confidence
  • ν ≥ 0: variance confidence

The parameters have a natural interpretation when used as a prior for a Normal distribution with unknown mean and variance: μ and σ2 are the expected mean and variance, while κ and ν are the respective degrees of confidence (expressed in "pseudocounts"). When interpretable parameters are important, this makes it a slightly more convenient parametrization of the conjugate prior.

Equivalent to a NormalInverseGamma distribution with parameters:

  • m0 = μ
  • v0 = 1/κ
  • shape = ν/2
  • scale = νσ2/2

Based on Murphy "Conjugate Bayesian analysis of the Gaussian distribution".

source
Utils.ScaledInverseChiSqFunction
ScaledInverseChiSq(ν,τ²)

Defines the Scaled inverse Chi2 distribution with location ν and scale τ.

This is a convenience function that is just calling InverseGamma(ν/2,ν*τ²/2)

Examples

julia> using Statistics: mean;
julia> using Distributions: pdf;
julia> dist = ScaledInverseChiSq(10,3^2);
julia> mean(dist)
11.25
julia> pdf(dist, 12)
0.06055632954714239
source
Utils.SimDirProcessFunction
SimDirProcess(P₀, α, ϵ)

Simulates one realization from the Dirichlet Process DP(α⋅P₀) using the Stick-breaking construction.

ϵ>0 is the remaining stick length when the simulation terminates.

Examples

julia> θ, π = SimDirProcess(Normal(), 5, 0.001);
julia> plot(-3:0.01:3, cdf.(Normal(), -3:0.01:3), label = "base", xlab = "x", 
    ylab = "F(x)", c = :red)
julia> plot!(θ, cumsum(π), linetype = :steppost, xlab = "θ", 
    ylab = "F(θ)", label = "realization")
source
Utils.NegativeBinomial2Function
NegativeBinomial2(μ, ϕ)

The negative binomial distribution in the mean (μ) and dispersion (ϕ) parameterization

μ is the mean and ϕ is the dispersion parameter so that E(y) = μ Var(y) = μ(1 + μ/ϕ)

Examples

julia> μ = 0.3; ϕ = 2.3;
julia> d = NegativeBinomial2(μ, ϕ);
julia> mean(d), μ # should be equal, up to numerical precision
0.2999999999999997
julia> var(d), μ*(1 + μ/ϕ) # should be equal, up to numerical precision
0.33913043478260835
source