Reference and Target Densities
Index
TransportMaps.MapReferenceDensityTransportMaps.MapTargetDensityDistributions.logpdfDistributions.pdfTransportMaps.grad_logpdf
Types
TransportMaps.MapTargetDensity Type
MapTargetDensityWrapper for target density functions used in transport map optimization. Stores the log-density function and its gradient, with support for automatic differentiation backends via DifferentiationInterface.jl.
Fields
logdensity<:Function: Function computing log-densitylog π(x)ad_backend<:Union{Nothing,ADTypes.AbstractADType}: AD backend ornothingfor analyticalgrad_logdensity<:Function: Function computing gradient∇ log π(x)prepared_gradient: Optional prepared gradient for performance (can benothing)
Constructors
MapTargetDensity(logdensity, grad_logdensity): Provide both log-density and analytical gradient.MapTargetDensity(logdensity, backend::ADTypes.AbstractADType, d::Int): Use AD backend with prepared gradient.MapTargetDensity(logdensity, backend::ADTypes.AbstractADType): Use AD backend without preparation.MapTargetDensity(logdensity): Use ForwardDiff.
Examples
# Use ForwardDiff (default, not prepared)
density = MapTargetDensity(logπ)
# Use ForwardDiff with prepared gradient (faster for repeated evaluations)
density = MapTargetDensity(logπ, AutoForwardDiff(), d)
# Use Mooncake with preparation
density = MapTargetDensity(logπ, AutoMooncake(), d)
# Use FiniteDiff
density = MapTargetDensity(logπ, AutoFiniteDiff(), d)
# Use analytical gradient
density = MapTargetDensity(logπ, grad_logπ)TransportMaps.MapReferenceDensity Type
MapReferenceDensityWrapper for reference density (typically standard Gaussian) used in transport maps. The reference density defines the space from which samples are drawn and mapped to the target distribution.
Fields
logdensity<:Function: Function computing log-densitylog ρ(z)ad_backend<:ADTypes.AbstractADType: AD backend for gradient computationgrad_logdensity<:Function: Function computing gradient∇ log ρ(z)densitytype::Distributions.UnivariateDistribution: Univariate density type (e.g.,Normal())prepared_gradient: Prepared gradient for performance (can benothing)
Constructors
MapReferenceDensity(): Use standard normal with ForwardDiff (default, not prepared).MapReferenceDensity(densitytype): Specify distribution with ForwardDiff (not prepared).MapReferenceDensity(densitytype, backend): Specify distribution and AD backend (not prepared).MapReferenceDensity(densitytype, backend, d): Specify distribution, AD backend, and dimension (prepared, recommended for performance).
Functions
Distributions.pdf Function
pdf(density::AbstractMapDensity, x)Evaluate the probability density at point(s) x.
Arguments
density::AbstractMapDensity: Target or reference densityx: Point (vector) or multiple points (matrix, rows are samples) at which to evaluate
Returns
- Scalar density value for vector input, or vector of densities for matrix input
Note
This computes exp(logpdf(density, x)). For numerical stability, prefer using logpdf when possible.
Distributions.logpdf Function
logpdf(density::AbstractMapDensity, x)Evaluate the log-density at point(s) x.
Arguments
density::AbstractMapDensity: Target or reference densityx: Point (vector) or multiple points (matrix, rows are samples) at which to evaluate
Returns
- Scalar log-density value for vector input, or vector of log-densities for matrix input
TransportMaps.grad_logpdf Function
grad_logpdf(density::AbstractMapDensity, x)Evaluate the gradient of log-density at point(s) x.
Arguments
density::AbstractMapDensity: Target or reference densityx: Point (vector) or multiple points (matrix, rows are samples) at which to evaluate
Returns
- Gradient vector for vector input, or matrix of gradients (one per row) for matrix input