specular.calculation.scaled_mean
scaled_mean(alpha, beta, sigma=1.0)
Evaluate the scaled angular mean elementwise. Also available as
specular.scaled_mean.
Parameters
| Name | Description |
|---|---|
alpha, beta |
Real scalars or broadcast-compatible arrays of slopes. |
sigma |
Concrete, finite, positive real scalar. Default: 1.0. |
Returns
A scalar or array with the broadcast shape of alpha and beta.
NumPy and Numba return a Python float for scalar results and a NumPy array
otherwise; JAX returns a JAX array. Arithmetic uses the selected backend's
calculation dtype.
Notes
The scale parameter defines
Inputs are promoted before arithmetic. Scale-safe formulas recover representable results when direct rescaling would overflow or underflow. The exact identities
are preserved for finite slopes even in those regimes. Other results remain
subject to the backend dtype's representable range and device treatment
of subnormal values. Under JAX transformations, alpha and beta may be
traced, but sigma must remain static.
See the calculation guide for background.
Examples
from specular.calculation import scaled_mean
print(scaled_mean(1.0, -0.5, sigma=2.0))
print(scaled_mean([1.0, 2.0], [-1.0, 2.0])) # [0. 2.]
Source code in specular/calculation.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |