<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj" -->

---
title: A neat little trick with time decay | daily.dev
description: A technique for computing time-decayed popularity scores without storing timestamps. Instead of tracking when each score was calculated, you factor out the...
canonical: https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: A neat little trick with time decay | daily.dev
og:description: A technique for computing time-decayed popularity scores without storing timestamps. Instead of tracking when each score was calculated, you factor out the...
og:url: https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj
og:image: https://api.daily.dev/og/posts/RO2UXhjVj.png
og:image:alt: A neat little trick with time decay
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A neat little trick with time decay

**[Erik Bernhardsson](https://daily.dev/sources/erikbernhardsson)** · 2 min read · 0 upvotes · 0 comments

## Summary

A technique for computing time-decayed popularity scores without storing timestamps. Instead of tracking when each score was calculated, you factor out the current time as a constant multiplier and store only the time-independent component. Because the raw accumulated value grows astronomically large, you store its logarithm instead. Adding new terms to a log-space sum is handled via a numerically stable log-sum-exp identity, avoiding overflow. This approach was used at Spotify for track popularity scoring.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://erikbern.com/2012/10/29/a-neat-little-trick-with-time-decay.html>

## Similar posts on daily.dev

- [RAG Is Blind to Time — I Built a Temporal Layer to Fix It in Production](https://daily.dev/posts/rag-is-blind-to-time-i-built-a-temporal-layer-to-fix-it-in-production-n1qi1u6py) · Towards Data Science · 1 upvotes · 0 comments
- [How YouTube Counts Millions of Live Viewers](https://daily.dev/posts/how-youtube-counts-millions-of-live-viewers-l3kj0h2bq) · Code Like A Girl · 3 upvotes · 1 comments
- [Stop Treating AI Memory Like a Search Problem](https://daily.dev/posts/stop-treating-ai-memory-like-a-search-problem-iq7rmxoe7) · Towards Data Science · 1 upvotes · 0 comments
- [Adding Temporal Reasoning to Graph-RAG: Tracking Fact Freshness and Staleness](https://daily.dev/posts/adding-temporal-reasoning-to-graph-rag-tracking-fact-freshness-and-staleness-iengqcl9o) · Machine Learning Mastery · 2 upvotes · 0 comments

---

Tags: [#data-engineering](https://daily.dev/tags/data-engineering)

[View this post on daily.dev](https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"A neat little trick with time decay","url":"https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj"},"datePublished":"2026-03-26T08:35:45.405Z","dateModified":"2026-03-26T08:36:46.629Z","description":"A technique for computing time-decayed popularity scores without storing timestamps. Instead of tracking when each score was calculated, you factor out the...","image":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","thumbnailUrl":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","isAccessibleForFree":true,"articleSection":"Erik Bernhardsson","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Erik Bernhardsson","logo":"https://media.daily.dev/image/upload/s--SlM88DTW--/f_auto,q_auto/v1774514112/logos/erikbernhardsson?_a=BAMAMiWQ0","url":"https://daily.dev/sources/erikbernhardsson"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/a-neat-little-trick-with-time-decay-ro2uxhjvj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"data-engineering","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Erik Bernhardsson","item":"https://daily.dev/sources/erikbernhardsson"},{"@type":"ListItem","position":3,"name":"A neat little trick with time decay"}]}
```

