fn

general_gaussian

Tensor
general_gaussian(M: int, p: float = 1.0, sig: float = 7.0, sym: bool = True, dtype: DTypeLike = None, device: DeviceLike = None)
source

Generalised Gaussian window.

Family parametrised by a shape exponent p and width sig, interpolating between the standard Gaussian (p = 1) and an increasingly flat-topped, sharper-edged window as p grows large. Useful when a Gaussian-like taper is desired but with more energy concentration in the centre samples.

Parameters

Mint
Number of samples in the output window; must be >= 0.
pfloat= 1.0
Shape exponent; p = 1 is the standard Gaussian, p > 1 flattens the top. Defaults to 1.0.
sigfloat= 7.0
Width parameter analogous to std; defaults to 7.0.
symbool= True
Symmetric (True, default) or periodic (False) variant.
dtypeDTypeLike= None
Desired dtype of the output tensor.
deviceDeviceLike= None
Target device for the output tensor.

Returns

Tensor

1-D tensor of length M.

Notes

Sample formula:

w[n]=exp ⁣(12n(N1)/22pσ2p),0n<N.w[n] = \exp\!\left( -\frac{1}{2} \frac{|n - (N-1)/2|^{2p}}{\sigma^{2p}} \right), \qquad 0 \le n < N.

As pp \to \infty the window approaches a rectangular shape of half-width σ\sigma.

Examples

>>> from lucid.signal.windows import general_gaussian
>>> general_gaussian(5, p=2.0, sig=1.5)
Tensor([0.4111, 0.9023, 1.0000, 0.9023, 0.4111])