Skip to content

Internal Documentation

Documentation for ConvolvedDistributions's internal interface.

Contents

Index

Internal API

Distributions.cdf Function
julia
cdf(d::UnivariateDistribution, x::Real)

Evaluate the cumulative probability at x.

See also ccdf, logcdf, and logccdf.

source
julia
cdf(d::ConvolvedDistributions.Convolved, x::Real) -> Any

Compute the cumulative distribution function.

Uses an analytical convolution when Distributions.convolve applies to all component pairs, otherwise AD-safe numeric quadrature.

See also: logcdf

source
julia
cdf(
    d::ConvolvedDistributions.Convolved,
    x::AbstractVector{<:Real}
) -> Any

Compute the CDF for a vector of evaluation points in one batched composite-quadrature pass.

Each point is integrated over the same window the scalar path picks, on a shared panel grid whose nodes and integration-component density are evaluated once and reused across points, plus small per-point end-correction integrals. Batched and scalar results therefore agree to well within ~1e-8 (typically near machine precision) for batches spanning up to ~40x point ranges; extreme spans (100x and beyond) stay within ~1e-6. See the FAQ.

See also: cdf

source
julia
cdf(d::Difference, z::Real) -> Any

Compute the cumulative distribution function.

Uses the analytic Normal-Normal difference where it applies, otherwise AD-safe numeric quadrature of   .

See also: logcdf

source
julia
cdf(d::ConvolvedDistributions.Product, z::Real) -> Any

Compute the cumulative distribution function.

Uses the analytic LogNormal-LogNormal product where it applies, otherwise AD-safe numeric quadrature of   in its survival form   , which stays accurate when Y's density diverges at zero (shape below one).

See also: logcdf

source
Distributions.components Function
julia
components(d::AbstractMixtureModel)

Get a list of components of the mixture model d.

source
julia
components(d::ConvolvedDistributions.Convolved) -> Tuple
julia
components(d::Convolved)

The independent delay distributions whose sum d represents, returned as the component tuple. The public accessor for peeling a Convolved apart without reaching into its fields — a downstream lower bridge, for one, folds them into a series phase-type chain. Extends Distributions.components (the standard composite-distribution accessor), so it composes with using Distributions rather than clashing with it.

source
Distributions.logcdf Function
julia
logcdf(d::UnivariateDistribution, x::Real)

The logarithm of the cumulative function value(s) evaluated at x, i.e. log(cdf(x)).

source
julia
logcdf(d::ConvolvedDistributions.Convolved, x::Real) -> Any

Compute the log cumulative distribution function.

See also: cdf

source
julia
logcdf(d::Difference, z::Real) -> Any

Compute the log cumulative distribution function.

See also: cdf

source
julia
logcdf(d::ConvolvedDistributions.Product, z::Real) -> Any

Compute the log cumulative distribution function.

See also: cdf

source
Distributions.logpdf Function
julia
logpdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the logarithm of the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of logpdf one should implement _logpdf(d, x) which does not have to check the size of x.

See also: pdf, gradlogpdf.

source
julia
logpdf(d::Distribution{ArrayLikeVariate{N}}, x) where {N}

Evaluate the logarithm of the probability density function of d at every element in a collection x.

This function checks for every element of x if its size is compatible with distribution d. This check can be disabled by using @inbounds.

Here, x can be

  • an array of dimension > N with size(x)[1:N] == size(d), or

  • an array of arrays xi of dimension N with size(xi) == size(d).

source
julia
logpdf(d::UnivariateDistribution, x::Real)

Evaluate the logarithm of probability density (mass) at x.

See also: pdf.

source
julia
logpdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the logarithm of the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
julia
logpdf(d::ConvolvedDistributions.Convolved, x::Real) -> Any

Compute the log probability density function.

See also: pdf, logcdf

source
julia
logpdf(
    d::ConvolvedDistributions.Convolved,
    x::AbstractVector{<:Real}
) -> Any

Compute log densities for a vector of points, reusing the batched PDF solve for the numeric path.

Each point is integrated over the same window the scalar path picks (shared composite panels plus per-point end corrections), so batched and scalar log densities agree to well within ~1e-8 even for wide batches (typically near machine precision; extreme 100x-plus point spans stay within ~1e-6).

See also: logpdf, pdf

source
julia
logpdf(d::Difference, z::Real) -> Any

Compute the log probability density function.

See also: pdf, logcdf

source
julia
logpdf(d::ConvolvedDistributions.Product, z::Real) -> Any

Compute the log probability density function.

See also: pdf, logcdf

source
Statistics.mean Function
julia
mean(d::UnivariateDistribution)

Compute the expectation.

source
julia
mean(d::MultivariateDistribution)

Compute the mean vector of distribution d.

source
julia
mean(d::MatrixDistribution)

Return the mean matrix of d.

source
julia
mean(d::Union{UnivariateMixture, MultivariateMixture})

Compute the overall mean (expectation).

source
julia
mean(d::ConvolvedDistributions.Convolved) -> Any

Mean of the convolution: the exact sum of the component means.

A Convolved is a sum of independent components, so the mean is . Each component must provide an analytic mean; a component without one errors (there is no numeric fallback).

See also: var, std

source
julia
mean(d::Difference) -> Any

Mean of the difference: the difference of the component means,  .

See also: var, std

source
julia
mean(d::ConvolvedDistributions.Product) -> Any

Mean of the product: the product of the component means,   (exact under independence).

See also: var, std

source
julia
mean(itr)

Compute the mean of all elements in a collection.

Note

If itr contains NaN or missing values, the result is also NaN or missing (missing takes precedence if array contains both). Use the skipmissing function to omit missing entries and compute the mean of non-missing values.

Examples

julia
julia> using Statistics

julia> mean(1:20)
10.5

julia> mean([1, missing, 3])
missing

julia> mean(skipmissing([1, missing, 3]))
2.0
source
julia
mean(f, itr)

Apply the function f to each element of collection itr and take the mean.

julia
julia> using Statistics

julia> mean(, [1, 2, 3])
1.3820881233139908

julia> mean([1, 2, 3])
1.3820881233139908
source
julia
mean(f, A::AbstractArray; dims)

Apply the function f to each element of array A and take the mean over dimensions dims.

Julia 1.3

This method requires at least Julia 1.3.

julia
julia> using Statistics

julia> mean(, [1, 2, 3])
1.3820881233139908

julia> mean([1, 2, 3])
1.3820881233139908

julia> mean(, [1 2 3; 4 5 6], dims=2)
2×1 Matrix{Float64}:
 1.3820881233139908
 2.2285192400943226
source
julia
mean(A::AbstractArray; dims)

Compute the mean of an array over the given dimensions.

Julia 1.1

mean for empty arrays requires at least Julia 1.1.

Examples

julia
julia> using Statistics

julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> mean(A, dims=1)
1×2 Matrix{Float64}:
 2.0  3.0

julia> mean(A, dims=2)
2×1 Matrix{Float64}:
 1.5
 3.5
source
Distributions.pdf Function
julia
pdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of pdf one should implement _pdf(d, x) which does not have to check the size of x. However, since the default definition of pdf(d, x) falls back to logpdf(d, x) usually it is sufficient to implement logpdf.

See also: logpdf.

source
julia
pdf(d::Distribution{ArrayLikeVariate{N}}, x) where {N}

Evaluate the probability density function of d at every element in a collection x.

This function checks for every element of x if its size is compatible with distribution d. This check can be disabled by using @inbounds.

Here, x can be

  • an array of dimension > N with size(x)[1:N] == size(d), or

  • an array of arrays xi of dimension N with size(xi) == size(d).

source
julia
pdf(d::UnivariateDistribution, x::Real)

Evaluate the probability density (mass) at x.

See also: logpdf.

source
julia
pdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
julia
pdf(d::ConvolvedDistributions.Convolved, x::Real) -> Any

Compute the probability density function.

Uses the exact analytical convolved density where Distributions.convolve applies to all component pairs, otherwise the AD-safe numeric density convolution    .

See also: logpdf

source
julia
pdf(
    d::ConvolvedDistributions.Convolved,
    x::AbstractVector{<:Real}
) -> Any

Compute densities for a vector of points in one batched composite-quadrature pass (see the batched cdf method).

See also: pdf

source
julia
pdf(d::Difference, z::Real) -> Any

Compute the probability density function.

Uses the exact analytic Normal-Normal density where it applies, otherwise the AD-safe numeric cross-correlation    .

See also: logpdf

source
julia
pdf(d::ConvolvedDistributions.Product, z::Real) -> Any

Compute the probability density function.

Uses the exact analytic LogNormal-LogNormal density where it applies, otherwise the AD-safe numeric Mellin convolution  .

See also: logpdf

source
julia
pdf(
    pmf::ConvolvedDistributions.DelayPMF,
    lag::Integer
) -> Any

Read the precomputed DelayPMF masses at integer lags.

pdf(pmf, lag) returns the discretised interval mass at lag (an integer, or a vector of integers for a batched read), reusing the build-once masses instead of re-evaluating CDF differences per lag. A lag outside 0..maxlag returns a zero of the PMF's element type (no mass is carried there). lag counts grid steps, not time units: for a PMF built with interval != 1, pdf(pmf, k) is the mass on [k * interval, (k + 1) * interval).

Arguments

  • pmf: a precomputed DelayPMF.

  • lag: an integer lag, or a vector of integer lags.

Examples

julia
using ConvolvedDistributions, Distributions

pmf = discretise_pmf(Gamma(2.0, 1.0), 10)
pdf(pmf, 3)
pdf(pmf, 0:5)

See also

source
Statistics.std Function
julia
std(d::UnivariateDistribution)

Return the standard deviation of distribution d, i.e. sqrt(var(d)).

source
julia
std(d::MultivariateDistribution)

Compute the vector of element-wise standard deviations for distribution d.

source
julia
std(d::ConvolvedDistributions.Convolved) -> Any

Standard deviation of the convolution, .

See also: var, mean

source
julia
std(d::Difference) -> Any

Standard deviation of the difference, .

See also: var, mean

source
julia
std(d::ConvolvedDistributions.Product) -> Any

Standard deviation of the product, .

See also: var, mean

source
julia
std(itr; corrected::Bool=true, mean=nothing[, dims])

Compute the sample standard deviation of collection itr.

The algorithm returns an estimator of the generative distribution's standard deviation under the assumption that each entry of itr is a sample drawn from the same unknown distribution, with the samples uncorrelated. For arrays, this computation is equivalent to calculating sqrt(sum((itr .- mean(itr)).^2) / (length(itr) - 1)). If corrected is true, then the sum is scaled with n-1, whereas the sum is scaled with n if corrected is false with n the number of elements in itr.

If itr is an AbstractArray, dims can be provided to compute the standard deviation over dimensions.

A pre-computed mean may be provided. When dims is specified, mean must be an array with the same shape as mean(itr, dims=dims) (additional trailing singleton dimensions are allowed).

Note

If array contains NaN or missing values, the result is also NaN or missing (missing takes precedence if array contains both). Use the skipmissing function to omit missing entries and compute the standard deviation of non-missing values.

source
Statistics.var Function
julia
var(d::UnivariateDistribution)

Compute the variance. (A generic std is provided as std(d) = sqrt(var(d)))

source
julia
var(d::MultivariateDistribution)

Compute the vector of element-wise variances for distribution d.

source
julia
var(d::MatrixDistribution)

Compute the matrix of element-wise variances for distribution d.

source
julia
var(d::UnivariateMixture)

Compute the overall variance (only for UnivariateMixture).

source
julia
var(d::ConvolvedDistributions.Convolved) -> Any

Variance of the convolution: the exact sum of the component variances.

Independence makes the variance additive, . As for mean, each component must provide an analytic var or the call errors.

See also: mean, std

source
julia
var(d::Difference) -> Any

Variance of the difference: the sum of the component variances,   (independence makes the variance additive even though the means subtract).

See also: mean, std

source
julia
var(d::ConvolvedDistributions.Product) -> Any

Variance of the product:   with   , exact under independence.

See also: mean, std

source
julia
var(itr; corrected::Bool=true, mean=nothing[, dims])

Compute the sample variance of collection itr.

The algorithm returns an estimator of the generative distribution's variance under the assumption that each entry of itr is a sample drawn from the same unknown distribution, with the samples uncorrelated. For arrays, this computation is equivalent to calculating sum((itr .- mean(itr)).^2) / (length(itr) - 1). If corrected is true, then the sum is scaled with n-1, whereas the sum is scaled with n if corrected is false where n is the number of elements in itr.

If itr is an AbstractArray, dims can be provided to compute the variance over dimensions.

A pre-computed mean may be provided. When dims is specified, mean must be an array with the same shape as mean(itr, dims=dims) (additional trailing singleton dimensions are allowed).

Note

If array contains NaN or missing values, the result is also NaN or missing (missing takes precedence if array contains both). Use the skipmissing function to omit missing entries and compute the variance of non-missing values.

source