Utils¶
Package¶
utils
¶
utils¶
Shared utility functions and helpers for psyphy.
This subpackage provides: - math : mathematical utilities (currently: basis functions, which may get their own module).
Functions:
| Name | Description |
|---|---|
chebyshev_basis |
Construct the Chebyshev polynomial basis matrix T_0..T_degree evaluated at x. |
chebyshev_basis
¶
chebyshev_basis(x: ndarray, degree: int) -> ndarray
Construct the Chebyshev polynomial basis matrix T_0..T_degree evaluated at x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Input points of shape (N,). For best numerical properties, values should lie in [-1, 1]. |
required |
degree
|
int
|
Maximum polynomial degree (>= 0). The output includes columns for T_0 through T_degree. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape (N, degree + 1) where column j contains T_j(x). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
Uses the three-term recurrence: T_0(x) = 1 T_1(x) = x T_{n+1}(x) = 2 x T_n(x) - T_{n-1}(x) The Chebyshev polynomials are orthogonal on [-1, 1] with weight (1 / sqrt(1 - x^2)).
Examples:
Source code in src/psyphy/utils/math.py
Math¶
math
¶
math.py
Math utilities for psyphy.
Includes: - chebyshev_basis : compute Chebyshev polynomial basis. - mahalanobis_distance : discriminability metric used in WPPM MVP. - rbf_kernel : kernel function, useful in Full WPPM mode covariance priors.
All functions use JAX (jax.numpy) for compatibility with autodiff.
Notes
- math.chebyshev_basis is relevant when implementing Full WPPM mode, where covariance fields are expressed in a basis expansion.
- math.mahalanobis_distance is directly used in WPPM MVP discriminability.
- math.rbf_kernel is a placeholder for Gaussian-process-style covariance priors.
Examples:
Functions:
| Name | Description |
|---|---|
chebyshev_basis |
Construct the Chebyshev polynomial basis matrix T_0..T_degree evaluated at x. |
chebyshev_basis
¶
chebyshev_basis(x: ndarray, degree: int) -> ndarray
Construct the Chebyshev polynomial basis matrix T_0..T_degree evaluated at x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Input points of shape (N,). For best numerical properties, values should lie in [-1, 1]. |
required |
degree
|
int
|
Maximum polynomial degree (>= 0). The output includes columns for T_0 through T_degree. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape (N, degree + 1) where column j contains T_j(x). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
Uses the three-term recurrence: T_0(x) = 1 T_1(x) = x T_{n+1}(x) = 2 x T_n(x) - T_{n-1}(x) The Chebyshev polynomials are orthogonal on [-1, 1] with weight (1 / sqrt(1 - x^2)).
Examples: