惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
宝玉的分享
宝玉的分享
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
Visual Studio Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
P
Proofpoint News Feed
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
Martin Fowler
Martin Fowler

HN's home page

Rainbow Query Language | Hacker News Exec into Node via Kubectl An AI native hedge fund The Seven-Action Documentation Model | Hacker News Package Manager for Kubectl Plugins Tongan Castaways | Hacker News Tech overlords plan for conscious AI to conquer the cosmos. What could go wrong? Data Breach Disclosure Lag Is Getting Worse How LLMs Work | Hacker News I Dropped PRDs for Shape Up Go Experiments Explained | Hacker News FCA's Palantir deal could expose UK financial data to Trump's US, critics fear WebXR BCI for Neural-Adaptive Avatar Control in Mixed Reality The first murder conviction via DNA analysis Tom Interviews Theo de Raadt of the OpenBSD Project (2019) [video] Show HN: Replace shell commands with bun shell typescript scripts Quay.io Is Down | Hacker News AI driven analysis of brokerage account fees in the UK Bill Gates Spent Years Crafting His Image. Now It's Cracking Using LLMs to secure source code Wi-Fi 8 in the Lab [video] The household battery revolution that could change energy bills and the world Is Python Becoming Pinyin? | Hacker News Livia – Executive Assistant | Hacker News FindMyPipe – Query Apple Find My from Linux for AI Agents Show HN: Agent skill for creating product launch videos with Remotion RecruitMyself – AI job search copilot for resumes and applications AI coding agents and the erosion of system understanding The 'Resting' Generation and South Korea's Youth Recession AMD Computex 2026: 10 Years of AM4, AM5 Support Through 2029
Why directory jumpers should use exponential moving sums ...
jghub · 2026-06-25 · via HN's home page

Directory jumpers such as z.sh and zoxide need to rank candidate directories from a stream of past navigation events. Most implementations use some form of frecency: a score combining historical visit count with recency.

The details vary, but the basic idea is always

   score = frequency × recency

where frequency measures how often a directory has been visited and recency depends on last visit time. After evaluating some tools, I have become convinced that this scoring model is wrong. The reason concerns the structure of the formula itself.

## Problem 1: historical visits never really disappear

Suppose a directory visited many times before but now dormant for months. A frecency system typically preserves the large historical count and only reduces the recency term. The directory therefore retains a large amount of "latent weight".

When visited again, the recency term resets while the historical count remains intact. Consequently, a directory that has been irrelevant for months can jump straight back to a top rank after a single revisit. Many users of directory jumpers have observed this behavior. It is one of the reasons people occasionally edit the database manually.

The underlying issue is that the scoring model stores

   (total historical usage) × (current recency)

rather than the decayed contribution of individual visits.

## Exponential moving sum (EMS)

A more natural model is to treat visits as unit impulses and let each individual impulse decay exponentially until query time

   score(t) = Σ exp(-λ(t - ti))

and to sum over all past visits. A long dormant directory, if revisited once, will get score≈1, independent of ancient visit history. This is exactly the same mathematical formalism that appears throughout signal processing and streaming statistics. Unix load averages are one example.

A remarkable property of EMS is that storing the full history is not required. Rather, recursive score computation is possible:

   score(t) = score(tlast) · exp(-λ(t - tlast)) + 1

requiring only the previous score and the timestamp of the last event.

## Problem 2: wall-clock time is not always meaningful

most directory jumpers use wall-clock time as their notion of time. Therefore, scores continue to decay during periods where no shell activity occurs (e.g. holidays). After a sufficiently long absence, all scores are pushed toward zero. The first few directories visited after returning then dominate the ranking, without good reason to treat the previously visited ones as having lost relevance in the meantime.

One alternative is to replace wall-clock time with an event-driven clock. This clock advances once per navigation event:

   tick = tick + 1

Under this model, time stops when the user is inactive. Decay reflects actually ongoing navigation activity rather than elapsed wall-clock time. This addresses a failure mode that is different from the frecency issue above. In fact, the two ideas are largely orthogonal:

* exponential moving sums solve the reanimation of long-dormant high-frequency entries

* event clocks prevent rankings from being distorted by long inactive periods

Why I ended up implementing this

I previously wrote a directory-navigation tool that stores complete event history and uses an event-clock exponential moving sum internally. Later I wondered how much of that behavior could be reproduced in a much simpler aggregate-state database similar to z.sh. That experiment became ze.sh.

The implementation turned out to be surprisingly small and tt accurately produces the desired EMS ranking behavior without need for retaining the full event stream.

What surprised me most is not that the approach works, but that exponential moving sums seem relatively uncommon in this category of tools despite being a standard solution in many other domains involving event streams and ranking.