Skip to content
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.eltype for uniform continuous distributions #1766

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/univariate/continuous/arcsine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Arcsine() = Arcsine{Float64}(0.0, 1.0)

@distr_support Arcsine d.a d.b

Base.eltype(::Type{<:Arcsine{T}}) where {T} = T


#### Conversions
function convert(::Type{Arcsine{T}}, a::Real, b::Real) where T<:Real
Arcsine(T(a), T(b))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/beta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Beta() = Beta{Float64}(1.0, 1.0)

@distr_support Beta 0.0 1.0

Base.eltype(::Type{<:Beta{T}}) where {T} = T

#### Conversions
function convert(::Type{Beta{T}}, α::Real, β::Real) where T<:Real
Beta(T(α), T(β))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/betaprime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ BetaPrime() = BetaPrime{Float64}(1.0, 1.0)

@distr_support BetaPrime 0.0 Inf

Base.eltype(::Type{<:BetaPrime{T}}) where {T} = T


#### Conversions
function convert(::Type{BetaPrime{T}}, α::Real, β::Real) where T<:Real
BetaPrime(T(α), T(β))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/biweight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Biweight(μ::Real=0.0) = Biweight(μ, one(μ); check_args=false)

@distr_support Biweight d.μ - d.σ d.μ + d.σ

Base.eltype(::Type{<:Biweight{T}}) where {T} = T


## Parameters
params(d::Biweight) = (d.μ, d.σ)
@inline partype(d::Biweight{T}) where {T<:Real} = T
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/cauchy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Cauchy(μ::Real=0.0) = Cauchy(μ, one(μ); check_args=false)

@distr_support Cauchy -Inf Inf

Base.eltype(::Type{<:Cauchy{T}}) where {T} = T

#### Conversions
function convert(::Type{Cauchy{T}}, μ::Real, σ::Real) where T<:Real
Cauchy(T(μ), T(σ))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/chi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Chi(ν::Integer; check_args::Bool=true) = Chi(float(ν); check_args=check_args)

@distr_support Chi 0.0 Inf

Base.eltype(::Type{<:Chi{T}}) where {T} = T

### Conversions
convert(::Type{Chi{T}}, ν::Real) where {T<:Real} = Chi(T(ν))
Base.convert(::Type{Chi{T}}, d::Chi) where {T<:Real} = Chi{T}(T(d.ν))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/chisq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Chisq(ν::Integer; check_args::Bool=true) = Chisq(float(ν); check_args=check_ar

@distr_support Chisq 0.0 Inf

Base.eltype(::Type{<:Chisq{T}}) where {T} = T

#### Parameters

dof(d::Chisq) = d.ν
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/cosine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Cosine(μ::Real=0.0) = Cosine(μ, one(µ); check_args=false)

@distr_support Cosine d.μ - d.σ d.μ + d.σ

Base.eltype(::Type{<:Cosine{T}}) where {T} = T


#### Conversions
function convert(::Type{Cosine{T}}, μ::Real, σ::Real) where T<:Real
Cosine(T(μ), T(σ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/epanechnikov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Epanechnikov(μ::Real=0.0) = Epanechnikov(μ, one(μ); check_args=false)

@distr_support Epanechnikov d.μ - d.σ d.μ + d.σ

Base.eltype(::Type{<:Epanechnikov{T}}) where {T} = T


#### Conversions
function convert(::Type{Epanechnikov{T}}, μ::Real, σ::Real) where T<:Real
Epanechnikov(T(μ), T(σ), check_args=false)
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/erlang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Erlang(α::Integer=1) = Erlang(α, 1.0; check_args=false)

@distr_support Erlang 0.0 Inf

Base.eltype(::Type{<:Erlang{T}}) where {T} = T


#### Conversions
function convert(::Type{Erlang{T}}, α::Integer, θ::S) where {T <: Real, S <: Real}
Erlang(α, T(θ), check_args=false)
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Exponential() = Exponential{Float64}(1.0)

@distr_support Exponential 0.0 Inf

Base.eltype(::Type{<:Exponential{T}}) where {T} = T


### Conversions
convert(::Type{Exponential{T}}, θ::S) where {T <: Real, S <: Real} = Exponential(T(θ))
function Base.convert(::Type{Exponential{T}}, d::Exponential) where {T<:Real}
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/fdist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ FDist(ν1::Real, ν2::Real; check_args::Bool=true) = FDist(promote(ν1, ν2)...;

@distr_support FDist 0.0 Inf

Base.eltype(::Type{<:FDist{T}}) where {T} = T

#### Conversions
function convert(::Type{FDist{T}}, ν1::S, ν2::S) where {T <: Real, S <: Real}
FDist(T(ν1), T(ν2))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/frechet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Frechet(α::Real=1.0) = Frechet(α, one(α); check_args=false)

@distr_support Frechet 0.0 Inf

Base.eltype(::Type{<:Frechet{T}}) where {T} = T

#### Conversions
function convert(::Type{Frechet{T}}, α::S, θ::S) where {T <: Real, S <: Real}
Frechet(T(α), T(θ))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Gamma() = Gamma{Float64}(1.0, 1.0)

@distr_support Gamma 0.0 Inf

Base.eltype(::Type{<:Gamma{T}}) where {T} = T

#### Conversions
convert(::Type{Gamma{T}}, α::S, θ::S) where {T <: Real, S <: Real} = Gamma(T(α), T(θ))
Base.convert(::Type{Gamma{T}}, d::Gamma) where {T<:Real} = Gamma{T}(T(d.α), T(d.θ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/generalizedextremevalue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function GeneralizedExtremeValue(μ::Integer, σ::Integer, ξ::Integer)
return GeneralizedExtremeValue(float(μ), float(σ), float(ξ))
end

Base.eltype(::Type{<:GeneralizedExtremeValue{T}}) where {T} = T


#### Conversions
function convert(::Type{GeneralizedExtremeValue{T}}, μ::Real, σ::Real, ξ::Real) where T<:Real
GeneralizedExtremeValue(T(μ), T(σ), T(ξ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/generalizedpareto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ GeneralizedPareto() = GeneralizedPareto{Float64}(0.0, 1.0, 1.0)
minimum(d::GeneralizedPareto) = d.μ
maximum(d::GeneralizedPareto{T}) where {T<:Real} = d.ξ < 0 ? d.μ - d.σ / d.ξ : Inf

Base.eltype(::Type{<:GeneralizedPareto{T}}) where {T} = T


#### Conversions
function convert(::Type{GeneralizedPareto{T}}, μ::S, σ::S, ξ::S) where {T <: Real, S <: Real}
GeneralizedPareto(T(μ), T(σ), T(ξ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/gumbel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Gumbel(μ::Real=0.0) = Gumbel(μ, one(μ); check_args=false)

@distr_support Gumbel -Inf Inf

Base.eltype(::Type{<:Gumbel{T}}) where {T} = T


const DoubleExponential = Gumbel

Base.eltype(::Type{Gumbel{T}}) where {T} = T
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/inversegamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ InverseGamma() = InverseGamma{Float64}(1.0, 1.0)

@distr_support InverseGamma 0.0 Inf

Base.eltype(::Type{<:InverseGamma{T}}) where {T} = T


#### Conversions
convert(::Type{InverseGamma{T}}, α::S, θ::S) where {T <: Real, S <: Real} = InverseGamma(T(α), T(θ))
function Base.convert(::Type{InverseGamma{T}}, d::InverseGamma) where {T<:Real}
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/inversegaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ InverseGaussian() = InverseGaussian{Float64}(1.0, 1.0)

@distr_support InverseGaussian 0.0 Inf

Base.eltype(::Type{<:InverseGaussian{T}}) where {T} = T


#### Conversions

function convert(::Type{InverseGaussian{T}}, μ::S, λ::S) where {T <: Real, S <: Real}
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/johnsonsu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ JohnsonSU(ξ::Real, λ::Real, γ::Real, δ::Real; check_args::Bool=true) = Johns

@distr_support JohnsonSU -Inf Inf

Base.eltype(::Type{<:JohnsonSU{T}}) where {T} = T


#### Conversions

Base.convert(::Type{JohnsonSU{T}}, d::JohnsonSU) where {T<:Real} = JohnsonSU{T}(T(d.ξ), T(d.λ), T(d.γ), T(d.δ))
Expand Down
1 change: 1 addition & 0 deletions src/univariate/continuous/kolmogorov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ end

@distr_support Kolmogorov 0.0 Inf


params(d::Kolmogorov) = ()


Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/kumaraswamy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Base.convert(::Type{Kumaraswamy{T}}, d::Kumaraswamy{T}) where {T} = d

@distr_support Kumaraswamy 0 1

Base.eltype(::Type{<:Kumaraswamy{T}}) where {T} = T

### Parameters

params(d::Kumaraswamy) = (d.a, d.b)
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/laplace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const Biexponential = Laplace

@distr_support Laplace -Inf Inf

Base.eltype(::Type{<:Laplace{T}}) where {T} = T


#### Conversions
function convert(::Type{Laplace{T}}, μ::S, θ::S) where {T <: Real, S <: Real}
Laplace(T(μ), T(θ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/levy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Levy(μ::Real=0.0) = Levy(μ, one(μ); check_args=false)

@distr_support Levy d.μ Inf

Base.eltype(::Type{<:Levy{T}}) where {T} = T


#### Conversions

convert(::Type{Levy{T}}, μ::S, σ::S) where {T <: Real, S <: Real} = Levy(T(μ), T(σ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/lindley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Base.convert(::Type{Lindley{T}}, d::Lindley{T}) where {T} = d

@distr_support Lindley 0.0 Inf

Base.eltype(::Type{<:Lindley{T}}) where {T} = T


### Parameters

shape(d::Lindley) = d.θ
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/logistic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Logistic(μ::Real=0.0) = Logistic(μ, one(μ); check_args=false)

@distr_support Logistic -Inf Inf

Base.eltype(::Type{<:Logistic{T}}) where {T} = T


#### Conversions
function convert(::Type{Logistic{T}}, μ::S, θ::S) where {T <: Real, S <: Real}
Logistic(T(μ), T(θ))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/logitnormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ LogitNormal(μ::Real=0.0) = LogitNormal(μ, one(μ); check_args=false)
@distr_support LogitNormal 0.0 1.0
#insupport(d::Union{D,Type{D}},x::Real) where {D<:LogitNormal} = 0.0 < x < 1.0

Base.eltype(::Type{<:LogitNormal{T}}) where {T} = T

#### Conversions
convert(::Type{LogitNormal{T}}, μ::S, σ::S) where
Expand All @@ -81,6 +82,7 @@ function Base.convert(::Type{LogitNormal{T}}, d::LogitNormal) where {T<:Real}
end
Base.convert(::Type{LogitNormal{T}}, d::LogitNormal{T}) where {T<:Real} = d


#### Parameters

params(d::LogitNormal) = (d.μ, d.σ)
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/lognormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ LogNormal(μ::Real=0.0) = LogNormal(μ, one(μ); check_args=false)

@distr_support LogNormal 0.0 Inf

Base.eltype(::Type{<:LogNormal{T}}) where {T} = T


#### Conversions
convert(::Type{LogNormal{T}}, μ::S, σ::S) where {T <: Real, S <: Real} = LogNormal(T(μ), T(σ))
Base.convert(::Type{LogNormal{T}}, d::LogNormal) where {T<:Real} = LogNormal{T}(T(d.μ), T(d.σ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/loguniform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ end

LogUniform(a::Real, b::Real; check_args::Bool=true) = LogUniform(promote(a, b)...; check_args=check_args)

Base.eltype(::Type{<:LogUniform{T}}) where {T} = T


Base.convert(::Type{LogUniform{T}}, d::LogUniform) where {T<:Real} = LogUniform{T}(T(d.a), T(d.b))
Base.convert(::Type{LogUniform{T}}, d::LogUniform{T}) where {T<:Real} = d

Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/noncentralbeta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ NoncentralBeta(α::Integer, β::Integer, λ::Integer; check_args::Bool=true) = N

@distr_support NoncentralBeta 0.0 1.0

Base.eltype(::Type{<:NoncentralBeta{T}}) where {T} = T


#### Conversions

function Base.convert(::Type{NoncentralBeta{T}}, d::NoncentralBeta) where {T<:Real}
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/noncentralchisq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ NoncentralChisq(ν::Integer, λ::Integer; check_args::Bool=true) = NoncentralChi

@distr_support NoncentralChisq 0.0 Inf

Base.eltype(::Type{<:NoncentralChisq{T}}) where {T} = T


#### Conversions

function convert(::Type{NoncentralChisq{T}}, ν::S, λ::S) where {T <: Real, S <: Real}
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/noncentralf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ NoncentralF(ν1::Integer, ν2::Integer, λ::Integer; check_args::Bool=true) = No

@distr_support NoncentralF 0.0 Inf

Base.eltype(::Type{<:NoncentralF{T}}) where {T} = T


#### Conversions

function convert(::Type{NoncentralF{T}}, ν1::S, ν2::S, λ::S) where {T <: Real, S <: Real}
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/noncentralt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ NoncentralT(ν::Integer, λ::Integer; check_args::Bool=true) = NoncentralT(float

@distr_support NoncentralT -Inf Inf

Base.eltype(::Type{<:NoncentralT{T}}) where {T} = T


### Conversions
convert(::Type{NoncentralT{T}}, ν::S, λ::S) where {T <: Real, S <: Real} = NoncentralT(T(ν), T(λ))
Base.convert(::Type{NoncentralT{T}}, d::NoncentralT) where {T<:Real} = NoncentralT(T(d.ν), T(d.λ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/normalcanon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ NormalCanon() = NormalCanon{Float64}(0.0, 1.0; check_args=false)

@distr_support NormalCanon -Inf Inf

Base.eltype(::Type{<:NormalCanon{T}}) where {T} = T


#### Type Conversions
convert(::Type{NormalCanon{T}}, η::S, λ::S) where {T <: Real, S <: Real} = NormalCanon(T(η), T(λ))
Base.convert(::Type{NormalCanon{T}}, d::NormalCanon) where {T<:Real} = NormalCanon{T}(T(d.η), T(d.λ); check_args=false)
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/normalinversegaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ end

@distr_support NormalInverseGaussian -Inf Inf

Base.eltype(::Type{<:NormalInverseGaussian{T}}) where {T} = T


#### Conversions
function convert(::Type{NormalInverseGaussian{T}}, μ::Real, α::Real, β::Real, δ::Real) where T<:Real
NormalInverseGaussian(T(μ), T(α), T(β), T(δ))
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/pareto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Pareto() = Pareto{Float64}(1.0, 1.0)

@distr_support Pareto d.θ Inf

Base.eltype(::Type{<:Pareto{T}}) where {T} = T

#### Conversions
convert(::Type{Pareto{T}}, α::Real, θ::Real) where {T<:Real} = Pareto(T(α), T(θ))
Base.convert(::Type{Pareto{T}}, d::Pareto) where {T<:Real} = Pareto{T}(T(d.α), T(d.θ))
Expand Down
7 changes: 5 additions & 2 deletions src/univariate/continuous/pgeneralizedgaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ to the normal distribution with `μ=0.0, σ=1.0`.
"""
PGeneralizedGaussian() = PGeneralizedGaussian{Float64}(0.0, √2, 2.0) # approximate scale with unity std deviation and shape 2

@distr_support PGeneralizedGaussian -Inf Inf

Base.eltype(::Type{<:PGeneralizedGaussian{T}}) where {T} = T


#### Conversions

function Base.convert(::Type{PGeneralizedGaussian{T}}, d::PGeneralizedGaussian) where {T<:Real}
return PGeneralizedGaussian{T}(T(d.μ), T(d.α), T(d.p))
end
Base.convert(::Type{PGeneralizedGaussian{T}}, d::PGeneralizedGaussian{T}) where {T<:Real} = d

@distr_support PGeneralizedGaussian -Inf Inf


#### Parameters
partype(::PGeneralizedGaussian{T}) where {T<:Real} = T
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/rayleigh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Rayleigh() = Rayleigh{Float64}(1.0)

@distr_support Rayleigh 0.0 Inf

Base.eltype(::Type{<:Rayleigh{T}}) where {T} = T


#### Conversions

convert(::Type{Rayleigh{T}}, σ::S) where {T <: Real, S <: Real} = Rayleigh(T(σ))
Expand Down
3 changes: 3 additions & 0 deletions src/univariate/continuous/rician.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Rician(ν::Integer, σ::Integer; check_args::Bool=true) = Rician(float(ν), floa

@distr_support Rician 0.0 Inf

Base.eltype(::Type{<:Rician{T}}) where {T} = T


#### Conversions

function convert(::Type{Rician{T}}, ν::Real, σ::Real) where T<:Real
Expand Down
Loading