Back to Admin Dashboard Algorithm Manual – Melatonin Suppression
Algorithm Manual
🌙 Melatonin Suppression Algorithm
Turns a screen’s real color and brightness into an estimated percent of melatonin suppression, using real eye-geometry (corneal illuminance) and the real published dose-response curve from peer-reviewed sleep research.
1Formula Reference & Its Peer Review

This page’s formula is built directly from one peer-reviewed study. Nothing on this page is invented math — every step either comes from that paper, from real measured pixels on the Sleep Planner page, or from a plainly-flagged assumption.

ℹ️ Giménez, M. C., Stefani, O., Cajochen, C., Lang, D., Deuring, G., & Schlangen, L. J. M. (2022). Predicting melatonin suppression by light in humans: Unifying photoreceptor-based equivalent daylight illuminances, spectral composition, timing and duration of light exposure. Journal of Pineal Research, 72(2), e12786.

That paper measured, in real people, how much light of different colors and brightness levels suppresses melatonin, and for how long people were exposed. It gives a real number called ED50 — the light dose needed to cause 50% suppression — and this number changes depending on how many minutes someone has been looking at the light.

2What Drives The Formula

Below is every factor the formula uses, in plain English. Anywhere this page guesses or assumes something instead of measuring it, that is flagged.

1
Average screen color (R, G, B)

Every pixel on the real Sleep Planner page, in sleep mode, is read and counted. All of them are then averaged into one overall red, green and blue value. This is measured, not guessed.

⚠️ Assumption: none here. We looked at the real page and counted the real colors, like counting jellybeans in a jar — no guessing.
2
Linear brightness (Y)

Screens store color in a boosted way so it looks right to human eyes. This step undoes that boost, so the math uses the screen’s true physical brightness fraction, not the display trick.

⚠️ Assumption: none here. This is just a standard fix every screen needs, like adjusting for how a camera sees color differently than your eye does.
3
Screen luminance (L)

The screen’s true brightness in real light units, found by multiplying the linear brightness (Y) by the screen’s peak brightness.

⚠️ Assumption: we guessed your screen’s brightest setting is 300 nits — about as bright as a laptop or phone set for normal indoor use. A brighter or dimmer screen would push the real number up or down a little.
4
Screen size & viewing distance

The physical size of the screen, and how far the eyes are from it. Both are needed to work out how much of a person’s view the screen actually fills.

⚠️ Assumption: we picked an everyday laptop and an everyday iPhone, held at a normal arm’s-length. Your own screen, and how close you hold it, could be a bit bigger, smaller, closer or further — which would nudge the number up or down.
5
Solid angle at the eye

How much of the person’s field of view the screen fills, worked out from real geometry: screen area divided by viewing distance squared. A bigger, closer screen fills more of the view.

⚠️ Assumption: none new here. It’s just simple geometry using the screen size and distance we already assumed in Step 4.
6
Corneal illuminance (E)

How much light actually lands on the eye. Found by multiplying the screen’s brightness (L) by the solid angle from Step 5. This is the real, physical light dose reaching the eye — not just how bright the screen looks.

⚠️ Assumption: none new here. It’s just multiplying two numbers we already worked out above, nothing extra guessed.
7
Color temperature (CCT)

A number in Kelvin describing how warm or cool a color looks. It is worked out purely from the average red, green and blue values in Step 1 — nothing else feeds into it. Warmer (lower K) light is gentler on melatonin; cooler, bluer (higher K) light is harsher.

⚠️ Assumption: none here. It comes straight out of the real screen color from Step 1, the same way you’d read a thermometer.
8
Melanopic ratio (Rm)

A score for how harsh a light’s specific color is on melatonin, based on its color temperature (CCT) from Step 7.

⚠️ Assumption: we used a formula found online to turn “warm or cool color” into a body-clock score, rather than the exact formula from the original scientists. Treat it as a sensible estimate, not a lab-proven fact.
9
Melanopic EDI

The real “melatonin-relevant” light dose. Found by multiplying corneal illuminance (E, Step 6) by the melanopic ratio (Rm, Step 8). This single number is what gets compared against the real published threshold in Step 10.

⚠️ Assumption: none new here. It’s the two numbers from Steps 6 and 8 multiplied together, nothing extra added.
10
Real ED50 threshold

A real, published number from Giménez et al. 2022: the light dose (in melanopic EDI) that causes 50% suppression, for a given number of minutes of viewing. This number is different for every exposure length — the longer someone looks at a light, the lower the dose needed to reach 50% suppression.

ℹ️ Real published values, directly from the paper: 30 min→600 lux, 60 min→350 lux, 120 min→120 lux, 180 min→43 lux, 240 min→15 lux (melanopic EDI). These fit a curve: ED50(minutes) = 1004 × e−1.052 × hours, matching the 5 published points almost exactly.
⚠️ Assumption: these numbers come from a lab test where people stared at one steady light in a dark room, not from real phone or laptop use. It’s the closest real science we have, but real life is messier than a lab.
11
Curve steepness (n)

Controls how sharply suppression ramps up once light passes the ED50 threshold from Step 10.

⚠️ Assumption: we borrowed a “steepness” number of 1.2 from an online source, not the original study. A different number here would make the suppression score climb faster or slower, like turning a dimmer switch quicker or slower.
12
Putting it together
Suppression % = 100 ÷ (1 + (ED50 ÷ melanopic EDI)n)

This compares the real light dose reaching the eye (melanopic EDI, Step 9) against the real published threshold for that viewing time (ED50, Step 10). The closer the dose is to, or above, the threshold, the higher the suppression percent.

⚠️ Assumption: none new here. This step just plugs every number from Steps 1 to 11 into one final formula, nothing extra guessed.
3Worked Examples — Sleep Planner, Sleep Mode

Both examples use a real, full pixel-by-pixel scan of the live Sleep Planner page with sleep mode switched on — every pixel on screen was read and counted, then averaged. Screen sizes shown are typical reference sizes (a common laptop size, and an iPhone 12) — not a measurement of any specific person’s own device.

🖥️
Example 1 — Desktop (1440 × 900)
1,296,000 px

Every color found on screen, sorted by pixel count. This is the real, full pixel count — not a sample. Colors under 0.08% of the screen are grouped into “Other.”

Color (RGB)Blue Level (0-100%)Pixels% of screen
0, 0, 00%876,02067.594%
48, 48, 4818.8%228,22217.610%
240, 248, 24897.3%65,6325.064%
16, 152, 13653.3%40,7563.145%
32, 144, 13653.3%9,0880.701%
40, 144, 13653.3%8,8590.684%
8, 8, 83.1%7,6200.588%
24, 144, 13653.3%4,9230.380%
16, 16, 166.3%4,7010.363%
216, 216, 21684.7%3,3830.261%
152, 152, 15259.6%2,4340.188%
255, 255, 255100%2,1630.167%
24, 24, 249.4%1,9140.148%
104, 104, 10440.8%1,6970.131%
88, 88, 8834.5%1,6110.124%
8, 104, 9637.6%1,5460.119%
136, 136, 13653.3%1,5190.117%
16, 144, 13653.3%1,5100.117%
232, 96, 8031.4%1,4940.115%
72, 72, 7228.2%1,2770.099%
224, 224, 22487.8%1,1240.087%
16, 80, 7228.2%1,1160.086%
248, 248, 24897.3%1,0930.084%
Other (452 minor colors)—26,2962.029%

Averaging every row above gives the overall screen color used below.

Input / StepValue
Average screen color (R,G,B)27.0, 33.9, 33.4
Linear brightness (Y, gamma undone)0.0148
Screen luminance (L, 300 cd/m² peak assumed)4.45 cd/m²
Screen size & distance (assumed: 15.4in laptop, 60cm)0.0688 m² @ 0.6m
Solid angle at eye0.191 sr
Corneal illuminance (E)0.849 lux
Color temperature (CCT)7736 K
Melanopic ratio (Rm, assumed formula)1.27
Melanopic EDI1.07 lux
Real ED50 for 60 min (Giménez et al. 2022)350 lux
Curve steepness n (assumed, unverified)1.2
Minutes viewed (separate input)60
Suppression, 1 Hour
0.10%
📱
Example 2 — Mobile (375 × 812)
304,500 px

Every color found on screen, sorted by pixel count. This is the real, full pixel count — not a sample. Colors under 0.08% of the screen are grouped into “Other.”

Color (RGB)Blue Level (0-100%)Pixels% of screen
0, 0, 00%162,37453.325%
48, 48, 4818.8%84,17927.645%
240, 248, 24897.3%12,3134.044%
16, 152, 13653.3%11,8063.877%
40, 144, 13653.3%3,1001.018%
216, 216, 21684.7%3,0430.999%
32, 144, 13653.3%2,7770.912%
8, 8, 83.1%2,7000.887%
16, 16, 166.3%1,8900.621%
255, 255, 255100%1,7510.575%
24, 144, 13653.3%1,2940.425%
232, 96, 8031.4%1,1770.387%
24, 24, 249.4%9470.311%
224, 224, 22487.8%9040.297%
208, 208, 20881.6%6360.209%
8, 0, 00%5580.183%
248, 248, 24897.3%5410.178%
192, 200, 20078.4%4030.132%
16, 136, 12850.2%3950.130%
224, 48, 7228.2%3870.127%
16, 144, 13653.3%3830.126%
8, 128, 12047.1%3640.120%
152, 152, 15259.6%3600.118%
232, 232, 23291.0%3390.111%
232, 104, 8834.5%3390.111%
80, 80, 8031.4%3130.103%
24, 112, 10440.8%3120.102%
24, 80, 8031.4%2710.089%
32, 96, 9637.6%2570.084%
Other (393 minor colors)—8,3882.754%

Averaging every row above gives the overall screen color used below.

Input / StepValue
Average screen color (R,G,B)35.5, 43.9, 43.2
Linear brightness (Y, gamma undone)0.0234
Screen luminance (L, 300 cd/m² peak assumed)7.01 cd/m²
Screen size & distance (iPhone 12, as given)0.0091 m² @ 0.3m
Solid angle at eye0.101 sr
Corneal illuminance (E)0.712 lux
Color temperature (CCT)7708 K
Melanopic ratio (Rm, assumed formula)1.26
Melanopic EDI0.90 lux
Real ED50 for 60 min (Giménez et al. 2022)350 lux
Curve steepness n (assumed, unverified)1.2
Minutes viewed (separate input)60
Suppression, 1 Hour
0.08%
Why mobile came out higher

Not because the phone screen is a different color — the colors are almost identical (both are the same warm charcoal/gold sleep theme). Mobile scores slightly higher because, on the smaller screen, the bright UI elements (cards, icons, white text) take up a bigger share of the total pixels. Less black background to dilute them, so the average brightness comes out a little higher.

Top colors behind these numbers
ColorBlue Level (0-100%)Where it dominates
0,0,0 (black)0%67.6% of desktop, 53.3% of mobile — main background
48,48,48 (charcoal)18.8%17.6% of desktop, 27.6% of mobile — card backgrounds
16,152,136 (teal-green)53.3%3.1% of desktop, 3.9% of mobile — a mid-range blue level (the near-white rows above score higher on this scale)

Blue Level (0-100%) here means: how strong the blue channel itself is, out of its highest possible value of 255 (blue ÷ 255 × 100). 0% = no blue at all. 100% = the strongest blue a screen can show. This measures each color’s actual blue output, not a share of its own color mix — so pure white correctly shows as 100% (maximum blue), well above a neutral gray.

4Conclusions About Sleep Planner
ℹ️ Sleep Planner’s Sleep Mode theme suppresses melatonin by roughly 0.08% to 0.10% over an hour of viewing, on both desktop and mobile. That is close to no effect at all.

The reason it is this low is not one single trick — it is three things stacking together. The theme is very dark (most of the screen is near-black, so real brightness reaching the eye is tiny). The few bright accents that do appear are a warm teal-green, not a cool blue-white, which keeps the melanopic ratio (Rm) lower than a plain white screen would give. And a phone or laptop held at arm’s length only fills a small slice of the field of view, so even a bright patch delivers far less light to the eye than the same brightness would up close. Section 5 below shows what happens when the “dark” part of that combination is removed.

This does not mean screens at night are always harmless. Real published lab measurements of ordinary phone use — full brightness, plain white content, held close, in an otherwise dark room — have measured 7% to 11% suppression after a couple of hours. Sleep Planner’s Sleep Mode avoids that by being dark and warm-colored by design, which is exactly what this page’s numbers show.

5What If: Full White Replaces The Black

This section keeps every assumption the same (screen size, viewing distance, 300 cd/m² peak brightness, 60 minutes viewed) and only changes one thing: every pixel is now pure white (255, 255, 255) instead of the sleep-mode colors above. This shows how much of Sleep Planner’s low suppression number comes specifically from being dark.

Input / StepDesktop, sleep mode (actual)Desktop, full whiteMobile, sleep mode (actual)Mobile, full white
Linear brightness (Y)0.01481.00.02341.0
Screen luminance (L)4.45 cd/m²300 cd/m²7.01 cd/m²300 cd/m²
Corneal illuminance (E)0.849 lux57.30 lux0.712 lux30.30 lux
Color temperature (CCT)7736 K6503 K7708 K6503 K
Melanopic ratio (Rm)1.271.0561.261.056
Melanopic EDI1.07 lux60.48 lux0.90 lux31.98 lux
Suppression, 1 hour0.10%10.84%0.08%5.36%
⚠️ Full white pushes desktop suppression about 108× higher, and mobile about 67× higher, than the actual dark Sleep Mode theme. The color temperature also drops slightly (6503K vs ~7700K) because pure white is a slightly warmer reference point than the small bright accents in the real page — but this makes almost no difference next to the huge brightness change. Brightness, not color, is what is doing almost all the work here.
6How The Pixel Data Is Measured
🔍 In plain terms, no guessing anywhere in this part:
  1. Open the real Sleep Planner page, sleep mode switched on.
  2. Take a full, exact picture of the whole screen, matching the real screen size exactly.
  3. Read the color of every single pixel in that picture — not a sample, every one.
  4. Round each pixel’s color slightly (to the nearest step of 8) so that thousands of near-identical shades from smooth edges and gradients count as one color, without changing what the color looks like.
  5. Count how many pixels landed in each rounded color.
  6. Sort by count. Anything under 0.08% of the screen gets grouped into “Other” so the list stays short.
  7. Average all the real pixel colors together to get one overall screen color, then run that through Steps 1–12 in Part 2 above.
7Recommendations

Based on everything above, here is practical advice in three areas: color choices, filters, and device habits. Each “avoid” line says why, using the real numbers from this page.

RGB Recommendations — What Designers Should Watch For
✅ Do: keep backgrounds dark. Aim for RGB numbers under about 50 on all three channels, like the sleep theme’s near-black background. Darkness is what does the most good, by far.
✅ Do: if you add a bright color, lean warm. Keep the Blue number lower than the Red number, like the site’s teal-green accent (16, 152, 136), where Blue isn’t the top channel.
⚠️ Avoid: near-white backgrounds (RGB numbers above about 200 on all channels). Because: brightness is the single biggest driver of the suppression score. Our own numbers on this page jumped from about 0.1% to over 10% just by turning black into white — the color barely mattered next to that.
⚠️ Avoid: colors where Blue is the highest number, like a bright cyan or ice-blue. Because: a high Blue number pushes the color temperature (CCT) up, which this formula treats as harsher on melatonin.
⚠️ Avoid: large white or pale blocks, like a full-width header or a big card. Because: the more of the screen that’s bright, the higher the score. A small bright patch matters little; a big one adds up fast.
Filter Recommendations
✅ Do: use a warm-tint overlay, like an amber or orange filter that shifts the whole screen’s color toward warm. This is the kind of change that actually lowers the color temperature (CCT) number in this formula, not just the brightness.
⚠️ Avoid: a plain black dimmer (an opacity overlay) on its own. Because: it lowers brightness, which does help, but it leaves the underlying colors just as blue as before. Brightness and color both matter — dimming alone only covers half the problem.
⚠️ Avoid: a plain grayscale filter. Because: removing color doesn’t reliably lower the color temperature number, and it also strips out the visual cues that help people read the screen, like colored buttons or warnings.
⚠️ Avoid: relying on a “blue light filter” alone, without also lowering brightness. Because: our own numbers show brightness matters more than color. A bright, warm screen can still suppress melatonin more than a dim, cooler one.
Other Recommendations — Device Settings & Usage Time
💡 Some of the biggest wins have nothing to do with app design — they’re about how the device is used:
  1. Turn the device’s own brightness down before bed, not just relying on a dark theme inside the app. Brightness is the number one factor in this formula.
  2. Turn on the device’s built-in night mode or warm color mode in the evening, on top of any in-app dark theme.
  3. Hold phones further away, or sit further back from a laptop screen. Distance cuts down how much light actually reaches the eye — the same math used throughout this page.
  4. Keep evening screen sessions short. The real published science (Giménez et al. 2022) shows that the longer someone looks at a light, the less bright it needs to be to cause the same effect — so a quick check before bed is safer than a long scroll.
💬

Katie AI

Swap Voice ↻
💡 Guided Triage mode active.