skills/llm/sliding-window-permutation-search/SKILL.md
Local search that slides a window of size p across a word sequence, brute-forcing all permutations within each window to minimize an objective like LLM perplexity
npx skillsauth add wenmin-wu/ds-skills llm-sliding-window-permutation-searchInstall 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 sequences too long for full factorial search, slide a small window (3-5 elements) across the sequence and exhaustively try all permutations within each window position. The prefix and suffix remain fixed while the window contents are reordered. This is O(n * p!) per pass — tractable for p <= 7 — and converges quickly as each window improves its local ordering.
import itertools
def sliding_window_optimize(sequence, score_fn, window_size=4, skip=1):
best = sequence[:]
best_score = score_fn(best)
improved = True
while improved:
improved = False
for start in range(0, len(best) - window_size + 1):
end = start + window_size
prefix = best[:start]
suffix = best[end:]
window = best[start:end]
for perm in itertools.permutations(window):
candidate = prefix + list(perm) + suffix
s = score_fn(candidate)
if s < best_score:
best = candidate
best_score = s
improved = True
return best, best_score
words = text.split()
result, score = sliding_window_optimize(
words, lambda w: perplexity(' '.join(w)), window_size=4)
[start:start+p], enumerate all p! permutationsdata-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