| """ |
| Construct functions that might achieve low C1 using analytical insights. |
| |
| Key insight: C1 = max(f*f) / (integral(f))^2 |
| For f supported on N discrete points with spacing dx = 0.5/N, |
| the autoconvolution f*f has 2N-1 points. |
| |
| If we think of f as a discrete signal, C1 is related to the |
| peak-to-average ratio of the autocorrelation of f. |
| |
| Approach: Use functions related to low-autocorrelation sequences. |
| """ |
| import numpy as np |
|
|
| def compute_c1(f_values, dx): |
| f = np.maximum(f_values, 0.0) |
| autoconv = np.convolve(f, f, mode='full') * dx |
| integral_sq = (np.sum(f) * dx) ** 2 |
| if integral_sq < 1e-20: |
| return 1e10 |
| return float(np.max(autoconv) / integral_sq) |
|
|
| N = 1000 |
| dx = 0.5 / N |
|
|
| |
|
|
| |
| f = np.ones(N) |
| print(f"Constant: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| f = np.linspace(0.1, 1.0, N) |
| print(f"Linear ramp: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| f = np.sqrt(np.linspace(0.01, 1.0, N)) |
| print(f"Sqrt: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| for tau in [0.5, 1.0, 2.0, 3.0]: |
| f = np.exp(-np.linspace(0, tau, N)) |
| print(f"Exp decay tau={tau}: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| for p in [0.5, 1.0, 1.5, 2.0]: |
| x = np.linspace(0.01, 1.0, N) |
| f = x**p |
| print(f"Power x^{p}: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| for p in [0.3, 0.5, 1.0]: |
| x = np.linspace(0.01, 1.0, N) |
| f = x**(-p) |
| print(f"x^(-{p}): C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| for h in np.arange(0.1, 1.0, 0.1): |
| for split in np.arange(0.1, 0.9, 0.1): |
| f = np.ones(N) |
| s = int(N * split) |
| f[:s] = h |
| c1 = compute_c1(f, dx) |
| if c1 < 1.6: |
| print(f"Step h={h:.1f} split={split:.1f}: C1 = {c1:.10f}") |
|
|
| |
| for sigma in [0.1, 0.2, 0.3, 0.5, 1.0]: |
| x = np.linspace(-1, 1, N) |
| f = np.exp(-x**2 / (2*sigma**2)) |
| print(f"Gaussian sigma={sigma}: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| x = np.linspace(0, 1, N) |
| f = np.minimum(2*x, 2*(1-x)) |
| print(f"Hat: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| x = np.linspace(0, np.pi, N) |
| f = (1 + np.cos(x)) / 2 |
| print(f"Raised cosine: C1 = {compute_c1(f, dx):.10f}") |
|
|
| |
| x = np.linspace(-1, 1, N) |
| f = np.maximum(1 - x**2, 0) |
| print(f"Epanechnikov: C1 = {compute_c1(f, dx):.10f}") |
|
|