Constructors and Utilities

PolyChaos.assign2multi — Function
assign2multi(x, i, ind)

Embed a univariate coefficient vector into a multivariate total-degree basis.

Arguments

  • x: univariate coefficients ordered by polynomial degree.
  • i: one-based coordinate index in ind.
  • ind: total-degree multi-index matrix.

Returns

A coefficient vector aligned with the rows of ind, with terms that depend on coordinates other than i set to zero.

source
PolyChaos.calculateMultiIndices — Function
calculateMultiIndices(d, n)

Construct the total-degree multi-index matrix for d variables through degree n.

Arguments

  • d: positive number of variables.
  • n: nonnegative maximum total degree.

Returns

A matrix whose rows are multi-indices in the ordering used by MultiOrthoPoly.

Examples

julia> using PolyChaos

julia> size(calculateMultiIndices(2, 2))
(6, 2)
source
PolyChaos.computeTensorizedSP — Function
computeTensorizedSP(m, basis)
computeTensorizedSP(m, alpha, beta, nodes, weights, ind; issymmetric)

Compute sparse tensorized scalar products of order m.

Arguments

  • m: positive scalar-product order.
  • basis: a univariate basis, coordinate-basis vector, or MultiOrthoPoly.
  • alpha, beta: recurrence coefficient vectors for each coordinate.
  • nodes, weights: quadrature data for each coordinate.
  • ind: multivariate basis multi-index matrix.

Keywords

  • issymmetric: coordinate symmetry flags used to eliminate zero products.

Returns

A sparse vector indexed by the polynomial-index tuples in the total-degree basis.

source
PolyChaos.dim — Function
dim(basis)

Return the number of polynomials represented by an orthogonal basis.

Arguments

For univariate bases this is deg(basis) + 1; for multivariate bases it is the number of rows in the total-degree multi-index matrix.

source
PolyChaos.findUnivariateIndices — Function
findUnivariateIndices(i::Int,ind::AbstractMatrix{Int64,2})

Given the multi-index ind this function returns all entries of the multivariate basis that correspond to the ith univariate basis.

Arguments

  • i: one-based coordinate index.
  • ind: total-degree multi-index matrix.

Returns

Indices of rows in ind corresponding to the univariate basis in coordinate i.

source
PolyChaos.genHermiteMeasure — Type
genHermiteMeasure(mu)

Generalized Hermite measure with weight abs(t)^(2mu) * exp(-t^2).

Arguments

  • mu: generalized-Hermite parameter; must exceed -0.5.

Fields

  • w, dom, symmetric: measure data.
  • muParameter: validated parameter.
source
PolyChaos.genHermiteOrthoPoly — Type
genHermiteOrthoPoly(deg, mu; Nrec = deg + 1, addQuadrature = true)

Construct a generalized Hermite basis.

Arguments

  • deg: nonnegative maximum degree.
  • mu: generalized-Hermite parameter greater than -0.5.

Keywords

  • Nrec: recurrence coefficient count.
  • addQuadrature: whether to attach Gaussian quadrature.

Fields

  • deg: maximum represented degree.
  • α, β: monic recurrence coefficients.
  • measure: generalized-Hermite measure.
  • quad: attached quadrature rule or EmptyQuad.
source
PolyChaos.genLaguerreMeasure — Type
genLaguerreMeasure(shape)

Generalized Laguerre measure with weight t^shape * exp(-t) on (0, Inf).

Arguments

  • shape: exponent of t; must exceed -1.

Fields

  • w, dom, symmetric: measure data.
  • shapeParameter: validated generalized-Laguerre shape.
source
PolyChaos.genLaguerreOrthoPoly — Type
genLaguerreOrthoPoly(deg, shape; Nrec = deg + 1, addQuadrature = true)

Construct a generalized Laguerre basis.

Arguments

  • deg: nonnegative maximum degree.
  • shape: generalized-Laguerre parameter greater than -1.

Keywords

  • Nrec: recurrence coefficient count.
  • addQuadrature: whether to attach Gaussian quadrature.

Fields

  • deg: maximum represented degree.
  • α, β: monic recurrence coefficients.
  • measure: generalized-Laguerre measure.
  • quad: attached quadrature rule or EmptyQuad.
source
PolyChaos.getentry — Function
getentry(a, T, ind, dim)

Return a sparse scalar-product tensor entry.

Arguments

  • a: zero-based polynomial indices; its length must equal dim.
  • T: sparse tensor storage returned by computeTensorizedSP.
  • ind: total-degree multi-index matrix used to construct T.
  • dim: scalar-product order.

a is sorted in place in descending order before lookup.

source
PolyChaos.golubwelsch — Function
golubwelsch(alpha, beta, maxiter = 30)

Compute Gaussian quadrature nodes and weights from monic recurrence coefficients using the Golub-Welsch eigenproblem.

Arguments

  • alpha, beta: equal-length recurrence coefficient vectors.
  • maxiter: maximum eigensolver iteration count.

Returns

Node and weight vectors for the associated Gaussian quadrature rule.

source
PolyChaos.multi2uni — Function
multi2uni(a, ind)

Convert scalar-product basis indices to coordinate-wise univariate indices.

Arguments

  • a: nonnegative row indices into ind, using PolyChaos's zero-based basis convention.
  • ind: total-degree multi-index matrix.

Returns

A matrix whose column j is the univariate multi-index represented by a[j].

source
PolyChaos.sampleInverseCDF — Function
sampleInverseCDF(n::Int, pdf::Function, dom::Tuple{<:Real,<:Real})

Inverse transform sampling using Chebyshev technology.

Draw n samples from a probability density function pdf with support dom. This method uses Chebyshev polynomial approximation of the PDF, constructs the CDF via integration, and then uses bisection to sample from the inverse CDF.

Based on:

  • Olver, Sheehan, and Alex Townsend. "Fast inverse transform sampling in one and two dimensions." arXiv preprint arXiv:1307.1223 (2013).
  • https://github.com/dlfivefifty/InverseTransformSampling

This method works for any bounded PDF and does not require log-concavity like adaptive rejection sampling.

Arguments

  • n::Int: Number of samples to draw
  • pdf::Function: Probability density function (need not be normalized)
  • dom::Tuple{<:Real,<:Real}: Domain (support) of the PDF as (lower, upper)

Returns

  • Vector{Float64}: Vector of n samples from the distribution

Example

# Sample from a truncated normal
pdf = x -> exp(-x^2/2)
samples = sampleInverseCDF(1000, pdf, (-3.0, 3.0))
source