Libra

What is a trend?

Introduction

Trends in Libra are a shorthand for moving average, a statistical technique to help extract meaningful results out noisy data.

Body weight is an inherently imprecise metric because we’re not only bags of flesh and bone, but also carry around everything we put into ourselves - generally in the form of drinks and food.

In short, if you weigh yourself before and after drinking a full glass of water, the weight difference will be the exact weight of the water minus the glass, unless you ate it as well. Do not eat glass.

Anyway, for this reason it’s recommended that you weigh yourself first thing in the morning just after waking up and using the toilet. It’s the closest to a common baseline most people will get.

For further reading check out The Hacker’s Diet - which inspired Libra more than 15 years ago - goes into great detail on using line smoothing for historical weight data: Signal and Noise.

How the trend is calculated

A trend value is calculated by taking the previous trend, calculating the difference to the current weight, multiplied by a smoothing factor.

Libra uses exponential smoothing which applies an exponentially decreasing weight to the time difference betweem both values as smoothing factor. This causes the trend to track large weight changes more accurately, and also adapts better to larger intervals between entries.

The formula is:

smoothingDays = 7
smoothingTime = smoothingDays * msPerDay
time = dateInMs - previousDateTime.inMs
power = 1 - e^(time / smoothingTime)
trend = previousTrend + power * (weight - previousTrend)

The smoothingDays variable can be adjusted in advanced preferences.