def silverman_bandwidth(X: np.ndarray) -> float: """ Compute optimal bandwidth via Silverman's rule of thumb. Args: X: Data matrix (n x d). Returns: Optimal bandwidth h. """ n, d = X.shape sigma = np.std(X, axis=0).mean() h = 1.06 * sigma * n ** (-1 / (d + 4)) return h # Example traces = np.random.randn(100, 3) h_opt = silverman_bandwidth(traces) print(f"Optimal h = {h_opt:.3f}")
There was an error while loading. Please reload this page.
Compitum Wiki