skills/timeseries/correlated-double-sampling/SKILL.md
Subtract paired reference frames from signal frames to cancel readout noise and common-mode bias
npx skillsauth add wenmin-wu/ds-skills timeseries-correlated-double-samplingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
For sensors with paired read/reset cycles, subtract even frames from odd frames (or vice versa) to cancel common-mode noise (kTC noise, bias drift, readout offsets). Halves the frame count but dramatically improves SNR. Common in astronomical detectors, IR sensors, and scientific imaging.
import numpy as np
def correlated_double_sampling(signal):
"""Subtract even (reset) frames from odd (read) frames.
Args:
signal: (..., T, ...) with T frames in read/reset pairs
Returns:
(..., T//2, ...) CDS-processed signal
"""
return signal[..., 1::2, :] - signal[..., ::2, :]
# Often followed by temporal binning
def cds_and_bin(signal, bin_size=10):
cds = correlated_double_sampling(signal)
n_bins = cds.shape[-2] // bin_size
binned = np.zeros((*cds.shape[:-2], n_bins, *cds.shape[-1:]))
for i in range(n_bins):
binned[..., i, :] = cds[..., i*bin_size:(i+1)*bin_size, :].mean(axis=-2)
return binned
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF