Health Insights Engine

Algorithmic Research Specification & Local Implementation Framework

This algorithmic research specification is designed for a local, on-device execution environment. By relying on deterministic heuristics, standard deviations, and established sports science formulas, this architecture provides a completely private insight engine that requires no external LLM latency and operates entirely on localized data structures.

1. Data Ingestion & Impedance Matching

The primary challenge in cross-platform health analysis is data standardization. Fitbit and Apple Health calculate metrics—specifically Heart Rate Variability (HRV)—differently.

The Improvisation: Z-Score Normalization

Because SDNN and RMSSD are mathematically distinct, raw absolute values cannot be reliably compared when a user switches devices. Instead, the engine evaluates physiological trends. By converting daily readings into rolling Z-scores, the engine normalizes the data against the user's own historical baseline, rendering the raw input metric agnostic.

2. Core Algorithmic Modules

Module A: Autonomic Balance (HRV & RHR)

Heart Rate Variability is exponential, not linear. Changes at the lower end (e.g., 20ms to 30ms) are biologically more significant than changes at the higher end.

1. Log-Transformation (HRV)

Apply a natural log to the daily HRV value to create a linear distribution that is easier to score:

HRVln = ln(HRVraw)

2. The 30-Day Z-Score

Calculate the rolling 30-day mean (μ) and standard deviation (σ) for both HRVln and Resting Heart Rate (RHR). Compare today's value against this baseline.

For HRV (higher is better):

ZHRV = (HRVln − μHRV) / σHRV

For RHR (lower is better, so the formula is inverted):

ZRHR = (μRHR − RHRtoday) / σRHR

Module B: Training Load & Optimal Strain

To prevent injury and optimize training, the engine utilizes the Acute:Chronic Workload Ratio (ACWR). This is the gold standard in sports science for determining if a user is safely adapting to workouts or risking injury.

ACWR = Acute Load7 / (Chronic Load28 / 4)

ACWR Thresholds:

Module C: Sleep Architecture

Instead of just scoring total duration, calculate Sleep Efficiency and Sleep Debt.

Efficiency = Total Time Asleep / Total Time in Bed

Sleep Score = (Actual Sleep / Baseline Need) × Efficiency × 100

Improvisation: Increase "Baseline Need" by 30-45 minutes on days following an ACWR > 1.3 to account for tissue repair.

3. The Unified Recovery Score

Combine the individual modules into a deterministic 0-100 scale. This formula weighs autonomic nervous system readiness heavily, as it is the most accurate predictor of systemic fatigue.

To map the unbounded Z-scores (-3.0 to +3.0) to a clean 0-100 scale, apply a clamp and multiplier:

Readiness = Clamp(50 + (ZHRV × 15) + (ZRHR × 15) + ((Sleep Score − 80) × 1.5), 0, 100)

4. Local Decision Tree (The Insights Generator)

With the math calculated, the engine runs a matrix to generate highly personalized, actionable text insights locally.

Metric State Physiological Condition Actionable Insight Output
ACWR > 1.5
HRV Z < -1.0
High strain + Systemic fatigue "Your training volume is peaking, but your nervous system is suppressed. High injury risk today. Swap your workout for active recovery (Zone 1) or complete rest."
ACWR < 0.8
HRV Z > 0.5
Detraining + Fully recovered "Your body is fully primed, but your recent training volume is dropping. Excellent day for a high-intensity threshold workout to build fitness."
RHR Z < -1.5
Sleep < 70
Acute stress + Sleep debt "Elevated resting heart rate and poor sleep indicate physiological stress. Hydrate heavily today and aim to get to bed 45 minutes earlier to clear your sleep debt."
ACWR 0.9-1.2
HRV Z > 0.0
The Sweet Spot "You are successfully absorbing your training load. Keep your current intensity—you are in the optimal zone for fitness gains."

References

1. Gabbett, T. J. (2016). The training—injury prevention paradox: should athletes be training smarter and harder? British Journal of Sports Medicine, 50(5), 273-280. (Establishes the ACWR formula and the 0.8-1.3 "Sweet Spot" threshold).
2. Plews, D. J., Laursen, P. B., Stanley, J., Kilding, A. E., & Buchheit, M. (2013). Training adaptation and heart rate variability in elite endurance athletes: opening the door to effective monitoring. Sports Medicine, 43(9), 773-781. (Validates the 7-day rolling average HRV baseline and coefficient of variation).
3. Altini, M., & Amft, O. (2016). HRV4Training: Large-Scale Longitudinal Training Load Analysis in Unconstrained Free-Living Settings Using a Smartphone Application. (Validates the logarithmic transformation for scaling autonomic readiness).
4. Shaffer, F., & Ginsberg, J. P. (2017). An Overview of Heart Rate Variability Metrics and Norms. Frontiers in Public Health, 5, 258. (Details the biological differentiation between RMSSD and SDNN measurement windows).