dsf.utils.integrators module¶
Numerical integration scripts for Delta Sigma calculations.
- dsf.utils.integrators.normalize_distribution(x, y)[source]¶
Normalize a one-dimensional distribution.
- Parameters:
x (ndarray[tuple[Any, ...], dtype[float64]]) – Coordinate array.
y (ndarray[tuple[Any, ...], dtype[float64]]) – Distribution values evaluated on
x.
- Returns:
Distribution values normalized so that their trapezoid integral over
xis one.- Raises:
ValueError – If the distribution integral is not positive.
- Return type:
ndarray[tuple[Any, …], dtype[float64]]
- dsf.utils.integrators.trapezoid_integral(y, x, *, axis=-1)[source]¶
Integrate values using the trapezoid rule.
- Parameters:
y (ndarray[tuple[Any, ...], dtype[float64]]) – Values to integrate.
x (ndarray[tuple[Any, ...], dtype[float64]]) – Coordinates along the integration axis.
axis (int) – Axis over which to integrate. If
yis one-dimensional, the result is a scalar. Ifyhas extra dimensions, the integration removes the selected axis and returns an array.
- Returns:
Integral of
ywith respect tox. Returns a scalar for a one-dimensional integral and an array for batched integrals.- Return type:
float | ndarray[tuple[Any, …], dtype[float64]]
- dsf.utils.integrators.weighted_trapezoid_average(x, values, weights, *, axis=0, normalize_weights=True)[source]¶
Compute a weighted trapezoid average along one axis.
- Parameters:
x (ndarray[tuple[Any, ...], dtype[float64]]) – Coordinate array for the integration axis.
values (ndarray[tuple[Any, ...], dtype[float64]]) – Values to average.
weights (ndarray[tuple[Any, ...], dtype[float64]]) – One-dimensional weights defined on
x.axis (int) – Axis of
valuescorresponding tox.normalize_weights (bool) – Whether to normalize
weightsbefore averaging. IfTrue, the returned value is a true weighted average. IfFalse, the returned value is the weighted integral.
- Returns:
Weighted average over
axis. Returns a scalar if all dimensions are integrated away, otherwise returns an array.- Return type:
float | ndarray[tuple[Any, …], dtype[float64]]