cutcutcodec.core.signal.window.alpha_to_band
- cutcutcodec.core.signal.window.alpha_to_band(alpha: float) float[source]
Empirical estimation based on regression.
The fitted model is (band = a*alpha + b + c*tanh(d*alpha)).
Examples
>>> import torch >>> from cutcutcodec.core.signal.window import find_dpss_law >>> alphas, _, bands = find_dpss_law() >>> alphas, bands = alphas.to(torch.float64), bands.to(torch.float64) >>> abcd = torch.tensor([0.990, 0.807, -0.714, 1.194], dtype=torch.float64, requires_grad=True) >>> optim = torch.optim.Adam([abcd]) >>> for _ in range(10000): ... pred = abcd[0]*alphas + abcd[1] + abcd[2]*torch.tanh(abcd[3]*alphas) ... optim.zero_grad() ... torch.mean((bands - pred)**2).backward() ... optim.step() ... >>> abcd.detach().to(torch.float32) tensor([ 0.9900, 0.8066, -0.7136, 1.1940]) >>> # import matplotlib.pyplot as plt >>> # _ = plt.plot(alphas.numpy(force=True), bands.numpy(force=True)) >>> # _ = plt.plot(alphas.numpy(force=True), pred.numpy(force=True)) >>> # plt.show() >>>