archimedes.measure.Measure¶
- class archimedes.measure.Measure¶
The weight and reference domain defining an orthogonal polynomial family.
A weight function \(w(x) \geq 0\) together with its support (the reference domain \(\mathcal{D}\)) defines an orthogonality measure \(d\mu(x) = w(x) \, dx\).
The polynomials orthogonal with respect to this measure also determine the nodes of the associated Gauss quadrature rule: for the degree-
northogonal polynomial, thenroots \(x_i\) and quadrature weights \(w_i\) satisfy\[\int_\mathcal{D} f(x) \, w(x) \, dx = \sum_{i=1}^n w_i f(x_i)\]exactly for every polynomial
fof degree \(\leq 2n - 1\).Subclasses implement one classical family each (Legendre, Jacobi, Laguerre, Hermite), pairing a weight with the
domainit lives on. The domain – the reference support and the affine map onto other instances of it – is factored out intoReferenceDomain, since several families share one (Legendre and Jacobi are bothUnitInterval; both Hermite conventions areRealLine) and since consumers with no weight function at all, such as a nodalBasis, need the domain without the measure.Methods
affine_params(*args, **kwargs)Return
(scale, shift)mapping the reference measure onto the requested instance of this family; forwarded todomain.affine_params.mass(*args, **kwargs)Total mass of the measure mapped by
affine_params(*args, **kwargs).Monic three-term recurrence coefficients, each shape
(n,).weight(x)Weight function \(w(x)\), evaluated at
x.Attributes
True if this measure's weight is provably the same shape, just relocated/rescaled, under
affine_params's reparametrization.Zeroth moment \(\int_\mathcal{D} w(t) ~ dt\) of the reference weight.
Support \(\mathcal{D} = [a, b]\); forwarded from
domain.True if the weight is constant (
weight(x) == weight(y)) for everyx,yinsupport-- e.g. true for Legendre, false for Jacobi (singular at the endpoints) or Hermite/Laguerre (unbounded support).The reference domain this measure's weight is supported on.
- __init__()¶
- affine_params(*args, **kwargs) tuple[float, float]¶
Return
(scale, shift)mapping the reference measure onto the requested instance of this family; forwarded todomain.affine_params.Quadrature weights pick up the same
scaleas a Jacobian factor, since \(dx = \mathrm{scale} \cdot dt\). The meaning of the arguments is domain-specific –a/bforUnitInterval,loc/scaleforRealLine,rate/startforHalfLine– see the correspondingReferenceDomainsubclass.
- mass(*args, **kwargs) float¶
Total mass of the measure mapped by
affine_params(*args, **kwargs).Equal to
scale * reference_mass, wherescaleis the affine scale factor. Dividing a mapped weight by this quantity turns it into a probability density on the mapped domain. Concrete subclasses don’t need to override this; it’s fully determined byaffine_paramsandreference_mass.
- recurrence_coeffs(n: int) tuple[ndarray, ndarray]¶
Monic three-term recurrence coefficients, each shape
(n,).The monic polynomials orthogonal with respect to this (reference) measure satisfy
\[\pi_{k+1}(x) = (x - \alpha_k) \, \pi_k(x) - \beta_k \, \pi_{k-1}(x), \qquad k = 0, \ldots, n-1,\]with \(\pi_{-1} = 0\), \(\pi_0 = 1\).
beta[0]plays no role in the recursion itself (since \(\pi_{-1} = 0\)) and is instead defined asreference_mass(see there for how it’s obtained by default) – the normalization Gauss quadrature (e.g. the Golub-Welsch algorithm) needs to recover quadrature weights from these coefficients.Only reference-instance coefficients are provided; a mapped instance’s coefficients follow from
affine_params(alpha' = scale * alpha + shift,beta' = scale**2 * betawithbeta'[0] = mass(...)), which callers can apply themselves.The default implementation falls back to a discretized Stieltjes procedure (
stieltjes_recurrence()), which numerically integrates the required moments viascipy.integrate.quadinstead of a closed form. Classical families override this method with a closed-form recursion for speed and much better high-degree accuracy.- Parameters:
n (int) – Number of coefficients to compute, i.e. degrees
0, ..., n-1. Must be>= 1; not validated here.
- affine_invariant: bool = False¶
True if this measure’s weight is provably the same shape, just relocated/rescaled, under
affine_params’s reparametrization. False (the default) for anything relying on the generic Stieltjes-basedrecurrence_coeffsfallback, since it is not guaranteed that an arbitrary weight family stays affine-closed.
- domain: ReferenceDomain¶
The reference domain this measure’s weight is supported on. Set as a class attribute by each concrete subclass; carries the
support,affine_paramsandParametersthatMeasuredelegates to.
- property reference_mass: float¶
Zeroth moment \(\int_\mathcal{D} w(t) ~ dt\) of the reference weight.
Since
affine_paramsonly ever rescales/shifts the reference domain, the zeroth moment of the mapped weight is alwaysscale * reference_mass, with no dependence onshift. This is the normalizing constant that turns the (raw) weight into a probability density,weight(x) / reference_mass. See alsomass, which generalizes this to a mapped instance.The default implementation numerically integrates
weightoversupportviascipy.integrate.quad(), so (together with the defaultrecurrence_coeffs()) a customMeasuresubclass needs onlyweightanddomainto be fully usable.
- property support: tuple[float, float]¶
Support \(\mathcal{D} = [a, b]\); forwarded from
domain.
- uniform_weight: bool = False¶
True if the weight is constant (
weight(x) == weight(y)) for everyx,yinsupport– e.g. true for Legendre, false for Jacobi (singular at the endpoints) or Hermite/Laguerre (unbounded support). Used by consumers that need to know whether the weight’s shape is trivial, e.g.archimedes.quadrature.composite_quad, which can only tile a rule across sub-elements when there’s no interior discontinuity in the weight to worry about.