torch.special.hermite_polynomial_he
function hermite_polynomial_he<S extends Shape>(x: Tensor<S, 'float32'>, n: number | Tensor, _options?: SpecialPolynomialOptions<S>): Tensor<S, 'float32'>Computes Hermite polynomial (probabilist's convention) He_n(x).
The Hermite polynomials of the probabilist's type He_n(x) are orthogonal on (-∞, ∞) with weight φ(x) = (1/√(2π)) exp(-x²/2), the standard Gaussian probability density. Related to physicist's convention by He_n(x) = 2^{-n/2} H_n(x/√2). Essential for:
- Probability theory: moments of Gaussian distribution, cumulants, Hermite series expansion of densities
- Statistical inference: quantile functions, tail approximations, extreme value analysis
- Machine learning: Gaussian process kernels, RBF networks, kernel methods with Gaussian basis
- Signal processing: matched filtering, optimal detection, Gaussian signals
- Polynomial chaos: Gaussian chaos polynomial expansion for surrogate modeling, UQ
- Hermite expansion: approximating any function in L²(φ) with normalized Gaussian weight
Probabilist's vs Physicist's: He_n grows as x^n (slower than 2^n x^n for physicist's H_n). Most natural convention in statistics/ML; physicist's H_n preferred in quantum mechanics.
Probability Connection: Moments of standard normal N(0,1): E[X^n] = ∫ x^n φ(x) dx = (0 if n odd, (n-1)!! if n even). Hermite polynomials encode these moments; roots give quadrature points for Gaussian integrals.
- Probabilist's convention: Natural for Gaussian/normal distributions and probability theory
- Slower growth than H_n: He_n(x) ~ x^n (vs H_n(x) ~ 2^n x^n); more numerically stable
- Gaussian orthogonality: Orthogonal with Gaussian density φ(x) = (1/√(2π)) exp(-x²/2) as weight
- Standard normal moments: E[He_n(X)] = 0, Var[He_n(X)] = n! for X ~ N(0, 1)
- Polynomial chaos: Natural basis for polynomial chaos expansion of Gaussian random variables
- Recurrence: Simpler than physicist's (coefficient n vs 2n); efficient for sequential computation
- Even/odd symmetry: He_n(-x) = (-1)^n He_n(x) (even if n even, odd if n odd)
- Slower convergence than H_n: Growth linear x^n (not 2^n x^n); but slower than physicist's doesn't mean slow overall
- Large n numerical issues: Still grows polynomially; overflow for n 100 and |x| 10
- Not physicist's convention: He_n ≠ H_n; related by factor 2^-n/2; ensure consistency in formulas
Parameters
xTensor<S, 'float32'>- Input tensor (unbounded real; well-defined for all x ∈ ℝ)
nnumber | Tensor- Polynomial degree (non-negative integer). Can be scalar or Tensor
_optionsSpecialPolynomialOptions<S>optional
Returns
Tensor<S, 'float32'>– Tensor with He_n(x) valuesExamples
// Basic evaluation
const x = torch.linspace(-2, 2, 5);
const He_0 = torch.special.hermite_polynomial_he(x, 0); // [1, 1, 1, 1, 1]
const He_1 = torch.special.hermite_polynomial_he(x, 1); // x
const He_2 = torch.special.hermite_polynomial_he(x, 2); // x^2 - 1
// Gaussian moment computation
const x_samples = torch.randn(10000); // Draw from N(0, 1)
const n_moment = 4;
const He_n = torch.special.hermite_polynomial_he(x_samples, n_moment);
const mean_He_n = He_n.mean(); // Approximate E[He_n(X)] = 0 (orthogonal)
// He_n has mean 0 and variance n! under standard Gaussian
// Polynomial chaos expansion for surrogate modeling
const x_input = torch.randn(50); // Uncertain input parameter
const n_basis = 4; // Order of polynomial chaos
const pc_basis = [];
for (let i = 0; i <= n_basis; i++) {
pc_basis.push(torch.special.hermite_polynomial_he(x_input, i));
}
// Orthogonal basis for approximating output uncertainty (Gaussian input)
// Gaussian quadrature points: roots of He_n are optimal quadrature nodes
// He_5(x) = x^5 - 10*x^3 + 15*x has 5 roots
// These roots with weights 5! / (5 * He'_5(root)^2) give exact integral for poly of degree ≤ 2n-1
// Comparison with physicist's convention
const x_comp = torch.tensor([1.0]);
const He_3 = torch.special.hermite_polynomial_he(x_comp, 3); // He_3(1) = 1 - 3 = -2
const H_3 = torch.special.hermite_polynomial_h(x_comp.mul(Math.sqrt(2)), 3); // H_3(√2) ≈ 8√2
// Verification: He_3(1) = 2^{-3/2} * H_3(1/√2) = 2^{-1.5} * 8√2 = -2 (scaled relation)
// Slower growth than physicist's H_n
const x_large = torch.tensor([10.0]);
const He_10 = torch.special.hermite_polynomial_he(x_large, 10); // He_10(10) ≈ 10^10 - ...
// Much smaller than H_10(10) ≈ 4.16e18; slower 1x vs 2^n scalingSee Also
- PyTorch torch.special.hermite_polynomial_he()
- torch.special.hermite_polynomial_h - Physicist's convention H_n(x) (faster growth, 2^n scaling)
- torch.special.laguerre_polynomial_l - Laguerre L_n on [0, ∞) with exp(−x) weight