Leo / Engines & Math

The math,
not the magic.

Ten calculation engines, all classical statistics, all running on your phone. Here's how every one of them actually works — formulas included, on purpose.

r = −0.74
What we built

Ten engines. Pearson correlations, linear regression, exponential time decay, z-scores — classical statistics, applied to chronic-illness data, computed on your device.

What we didn't build

No LLMs reading your data. No predictive forecasts we can't explain. No vendor model where the score is a black box.

Scroll for the receipts
A note from the founder

Why we built on classical statistics instead of plugging into a generic ML library — because privacy meant the math had to live on your phone; because transparency meant you should be able to read the formula; and because chronic-illness data behaves nothing like the fitness-app data those libraries were trained on.

Below the hood

Ten engines, end to end. Each one observes. None of them prescribes.

Each engine takes a stream of your logs, runs a specific statistical procedure on it, and surfaces what it found. You decide what to do with the answer.

Engine 01 · Migraine Risk

Migraine Prediction

Looks at the weather, your cycle phase, your sleep, and how often migraines have hit you in the past — at this hour, on this day of the week, after this kind of barometric drop. Combines those signals into a daily risk number, capped between zero and one.

ƒ  Daily risk
~18ms on device
risk = clamp[0,1] (Σ wᵢ · signalᵢ × dayMult × hourMult)
Inputs
  • Attack history
  • Environmental snapshots
  • Cycle phase
  • Sleep hours
Outputs
  • Daily risk gauge (0–1)
  • Top contributing factors
  • 7-day forecast overlay
RISK0.00
Weather (barometric drop)+0.28
Cycle phase (luteal late)+0.22
Sleep deficit+0.18
Day-of-week prior+0.11
Engine 02 · Trigger Decay

Correlation Learning Engine

Every time you confirm a trigger — “yes, dairy did cause that flare” — its weight ticks up by 0.1, capped at 1.0. Dismissals subtract 0.15. And every confirmation fades exponentially over 90 days, because a trigger you confirmed last spring isn't as relevant today as the one you confirmed Tuesday.

ƒ  Effective weight today
~3ms on device
effectiveWeight = rawWeight × e(−daysSinceConfirmation / 90)
Inputs
  • Confirmed (trigger → symptom) links
  • Dismissals
  • Confirmation dates
Outputs
  • Ranked trigger list
  • Suggested correlations to confirm
  • Personalized decay window
Try it

Drag to watch a confirmation fade over time.

After 30 days
0.717
0.000.250.500.751.000d90d180d270d365dweight
1d365d
At τ = 90 days the weight has fallen to e−1 ≈ 0.368 of its original value. After a year it's near zero — exactly when the trigger probably stopped being a trigger.
Engine 03 · Correlation Discovery

On-Device Pattern Engine

Computes Pearson correlations across every pair of things you've logged — sleep vs. mood, hydration vs. headache severity, weather vs. flare frequency. The strongest pairs bubble up. Everything runs on the phone; nothing is sent anywhere.

ƒ  Pearson correlation coefficient
~45ms / 200 days
r = Σ(xᵢ )(yᵢȳ) / √(Σ(xᵢ )2 · Σ(yᵢ ȳ)2)
Inputs
  • Daily sleep, mood, hydration
  • Vitals
  • Weather snapshots
Outputs
  • Correlation rankings
  • Threshold insights
  • Interaction pairs
Sleep
Mood
Hydration
Headache
Weather
Sleep
0.62
0.41
-0.55
-0.12
Mood
0.62
0.33
-0.48
-0.07
Hydration
0.41
0.33
-0.39
0.04
Headache
-0.55
-0.48
-0.39
0.46
Weather
-0.12
-0.07
0.04
0.46
inverse
positive
opacity = |r|
Engine 04 · Medication Effect

Symptom Insights Engine

off med
7.2
on med
4.1
Δ −3.1
avg severity
Sample comparison over n = 124 days. Confidence reported alongside the effect; effects under the noise floor are suppressed.

Compares your symptom severity in periods when you were taking a medication versus when you weren't, runs a linear regression to detect drift over time, and uses chi-squared to check whether certain cycle phases see disproportionate symptom counts.

ƒ  Effect estimate
~12ms on device
Δ = avg(severity | on med) − avg(severity | off med)
Inputs
  • Symptom logs (severity 0–10)
  • Dose logs
  • Sleep, vitals, weather, cycle
Outputs
  • Typed insights with confidence
  • Direction of effect
  • Effect sizes
Engine 05 · Heart-Rate Variability

ECG & SDNN

When you record an ECG on your Apple Watch, Leo extracts the R-peaks, measures the time between heartbeats, and computes the standard deviation of those intervals. That's SDNN — the standard clinical measure of heart-rate variability.

ƒ  SDNN (ms)
~32ms on device
SDNN = √(Σ(RRᵢ R̄R)2 / (n − 1))
Inputs
  • ECG voltage waveform
  • Sampling frequency
  • Artifact filter (300–2000ms)
Outputs
  • SDNN (milliseconds)
  • Average HR
  • Rhythm classification
mean + 1.5σRRRRRRR
HR 78 bpm · SDNN 42 ms
n = 6 R-peaks
Engine 06 · Post-Exertion Tracking

Activity → Symptom Correlation

For each kind of exertion you log, Leo counts how often a symptom flared within the next 24 hours. Then it divides by how many times that exertion happened total. The result is a “follow rate” — the fraction of times that activity is followed by a symptom.

ƒ  Follow rate
~6ms on device
followRate = symptomsWithin24h(activityType) / totalOccurrences(activityType)
Inputs
  • Activity logs (type, intensity, duration)
  • Symptom logs
Outputs
  • Follow rates per activity
  • Avg delay until symptom
  • Linked trigger summaries
What follows a heavy workout

9 symptom episodes followed within 24 hours

follow rate
0.68
activity+24h
Avg delay 10.1h · Range 1.2 – 22.5h
Engine 07 · Anomaly Detection

Multivariate Pattern Engine

Aggregates everything to a daily vector — sleep hours, mood, vitals, symptom counts — and flags days that sit more than two standard deviations from your rolling baseline. It also runs lagged cross-correlations to catch effects that show up days later, not the same day.

ƒ  Z-score anomaly flag
~22ms on device
z = (xₜμ₃₀) / σ₃₀ ·· flag if |z| > 2
Inputs
  • Daily feature vector
  • 30-day rolling baseline
  • Lag windows 1–7d
Outputs
  • Anomaly days
  • Multi-factor patterns
  • Time-lagged correlations
μ+2σz = 3.7
30-day window · 1 anomaly flagged
Engine 08 · Daily Wellness Index

Holistic Health Score

Base+75
Adherence +5+5
Sleep +5+5
Journal +5+5
Activity +5+5
Severity −16-16
Today79

A simple, transparent 0–100 score that starts at a base of 75 and adjusts. Severity drags it down. Medication adherence, sleep, journaling, and workouts each add a fixed bonus. No mystery weighting, no learned parameters — every input's contribution is visible.

ƒ  Daily score
~1ms on device
score = clamp[0,100](75 − 2·severity + 5·adherence + 5·sleep + 5·journal + 5·activity)
Inputs
  • Symptom severity
  • Adherence flags (4 categories)
Outputs
  • Daily score 0–100
  • Per-category contribution breakdown
Engine 09 · Vital Trends

Vital Trend Analyzer

For each vital you track — heart rate, blood pressure, glucose, SpO₂ — fits an ordinary least-squares line across a rolling 7–14 day window. Reports the slope, the percent change against the prior period, and an R² goodness-of-fit so weak trends don't masquerade as strong ones.

ƒ  Linear fit
~5ms / vital
ŷ = β₀ + β₁ · t ·· R2 = 1 − SSres / SStot
Inputs
  • 7–14 day vital window
  • Sample timestamps
Outputs
  • Trend direction
  • % change vs prior
  • R² confidence
β₁ = -1.42 / day
% change −14.6%R2 = 0.81
Engine 10 · As-Needed Medication

PRN Effectiveness

For every as-needed medication you take, Leo tracks severity before and after, computes the percent reduction, and groups results by the symptom you took it for. Helps you see which PRN actually does something for migraine vs. nausea vs. anxiety — instead of all of them blurring together.

ƒ  Severity reduction
~2ms / dose
reduction = (beforeafter) / before × 100%
Inputs
  • PRN dose logs
  • Pre / post severity (0–10)
  • Symptom type tagged
Outputs
  • Avg effectiveness %
  • Per-symptom efficacy
  • Side-effect frequency
Migraine65%
before 7.4after 2.6
Nausea51%
before 6.1after 3
Anxiety24%
before 5.8after 4.4

Every calculation on this page runs on your phone. No PHI is uploaded for analysis. The math is the product; we don't need your data to be ours.

Math you can read. App you can shape.

Want to see all ten engines, doing their thing?

Leo is in private beta. Join us to put these engines on your own data — and help shape what gets built next.