Marathon (or other distance) "real time" finish time estimator

Former Member
Former Member
Hi - Just moved over to Garmin from Suunto. There I was able to write a very simple app which would predict a marathon finish time. I can't find anything similar here and wondered if someone could point me in the right direction or make one. I'll try myself but first impressions are this seems far more complicated than the Suunto app builder.

Essentially, there are plenty of apps which will take average pace and convert that to a finish time. But, if you are speeding up or slowing down in the final few miles that doesn't help. With my Suunto I had an app that predicted the finish time in the following way

for the first 7k it would predict the estimated finish time based on actual accrued time for distance done predicting future time based on current 30 second average speed
for 7-14k it would base it on actual accrued time for distance done then 20% current 30 second average speed and 80% overall average speed
for 14-21k it woudl base it on actual accuted time for distance done then 40% current 30 second average speed and 60% overall average speed
for 21 - 28 actual plus 60% current 30 second average, 40% overall average
for 28-35 actual plus 80% current 30 second average, 20% overall average
for 35-39 actual plus 67% current 30 second average 33% current average
for 39-40 actual plus 33% current 30 second average 67% current average
for 40-41 actual plus 100% current average

The advantage of this was that in the early miles there was a heavy weighting on the current average as this is what you would hope to achieve (and the the 30s average helped stabalise the figures) but as you got close to the finish the overall average becomes less relevant and the actual pace you are running far more relevant. If you run 40k at an average of 4 minutes for a k but then walk the last 2 at 10 minutes a k an estimator would be way out using 4.x as a predicted finish.

Anyone know of an app like this or could help write one? The code I used with Suunto is below. (I had similar apps for 10k, HM and M - and had distance as 10.1, 13.2 and 26.4 to allow for the extra we all do - not sure if that is a possible input variable)

Thanks



/* While in sport mode do this once per second */

RESULT = 0;

if (SUUNTO_DISTANCE < 7 ) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
SUUNTO_AVG_SPD *3600);
}
if (SUUNTO_DISTANCE >= 7 && SUUNTO_DISTANCE < 14) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.2) +(SUUNTO_AVG_SPD * 0.8))*3600);
}
if (SUUNTO_DISTANCE >= 14 && SUUNTO_DISTANCE < 21) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.4) +(SUUNTO_AVG_SPD * 0.6))*3600);
}
if (SUUNTO_DISTANCE >= 21 && SUUNTO_DISTANCE < 28) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.6) +(SUUNTO_AVG_SPD * 0.4))*3600);
}
if (SUUNTO_DISTANCE >= 28 && SUUNTO_DISTANCE < 35) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.8) +(SUUNTO_AVG_SPD * 0.2))*3600);
}
if (SUUNTO_DISTANCE >= 35 && SUUNTO_DISTANCE < 39) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
SUUNTO_SPEED_AVG[30] * 3600);
}
if (SUUNTO_DISTANCE >= 39 && SUUNTO_DISTANCE < 40) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.67) +(SUUNTO_SPEED * 0.33))*3600);
}
if (SUUNTO_DISTANCE >= 40 && SUUNTO_DISTANCE < 41) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /
((SUUNTO_SPEED_AVG[30] * 0.33) +(SUUNTO_SPEED * 0.67))*3600);
}
if (SUUNTO_DISTANCE >= 41) {
RESULT = SUUNTO_DURATION + ((MARAKM - SUUNTO_DISTANCE) /SUUNTO_SPEED * 3600);
}
  • if no one takes you up on this, and if you have some coding experience, this would be pretty simple to do in a datafield. You posted the logic for it, and you would just have to tie that in to that data you have in "compute()", and do the return formatted like you want.

    You have access to distance (info.elapedDistace is in meters), and time (info.elapsedTime is in milliseconds), and speed (info.currentSpeed is in meters per second, and there's also info.averageSpeed) You might need to do a couple things yourself like if SPEED_AVG[30] is a 30 second avg, but that's not hard to do.
  • Hey, if you have a newer watch (*), I have a datafield called AppBuilder that can do math like this without having to code and build a full app. (*) Forerunner 645 Music, Fenix 5X, Fenix 5 Plus

    If not, I guess you'll have to take Jim's advice.

    https://apps.garmin.com/en-US/apps/fd690281-9c22-4fee-a81e-3b7f39aa67c5

    Try this formula:
    setv(1, ifs(distance_raw lt 7000, 0, distance_raw lt 14000, 0.2, distance_raw lt 21000, 0.4, distance_raw lt 28000, 0.6, distance_raw lt 35000, 0.8,distance_raw lt 39000, 1,distance_raw lt 40000, 0.67, distance_raw lt 41000, 0.33,1, 0)) ; timer + (42195 - distance_raw) / (getv(1) * timeavg(speed_raw, 30) + if(distance_raw lt 39000, 1 - getv(1), 0) * avgspeed_raw + if (distance_raw gte 39000, 1 - getv(1), 0) * speed_raw)

    And use display format: time

    Of course, a huge limitation of my app is that formulas over a certain complexity will not work (but you'll know when you press START).

    If you don't have one of those watches, AppBuilder is still available, but a formula that complicated just won't work because they don't have enough memory. (Translating the formula into code wastes a lot memory.)
  • Here's the same formula with line breaks and alignment so it's more readable. Sorry for the multiple posts, the forum doesn't like brackets.
    setv(1,
    ifs (distance_raw lt 7000, 0,
    distance_raw lt 14000, 0.2,
    distance_raw lt 21000, 0.4,
    distance_raw lt 28000, 0.6,
    distance_raw lt 35000, 0.8,
    distance_raw lt 39000, 1,
    distance_raw lt 40000, 0.67,
    distance_raw lt 41000, 0.33,
    1, 0))
    ;
    timer +
    (42195 - distance_raw) /
    (getv(1) * timeavg(speed_raw, 30) +
    if (distance_raw lt 39000, 1 - getv(1), 0) * avgspeed_raw +
    if (distance_raw gte 39000, 1 - getv(1), 0) * speed_raw)


    Quick explanation:
    distance_raw: distance in metres
    timer: activity timer in seconds
    avgspeed_raw: average speed in m/s
    speed_raw: current speed in m/s
    lt: less than
    gte: greater than or equal
    timeavg: rolling average over time
    getv: get user variable
    setv: set user variable
  • Former Member
    Former Member over 6 years ago
    Thanks both.

    Jim - yes, I'm guessing it should be fairly straightforward. Problem is I spent half an evening just trying to workout what I should download to get to something where I could attempt to program it. I'll take another look but all the instructions seemed to cross reference things!

    Flow - yes, its a newer watch. 5 Plus. Not got it yet, arriving Monday, but with a marathon next weekend wanted to see if I could get this app programmed ready so I could use it straight away! I'll try that code. Thanks!
  • One level up in the forums is the developer forum.

    The basics are, install the latest eclipse, the CIQ plugin, then the SDK.

    Or, if you first download the SDK from Here, there's a readme file with the basic steps, and the Programmer's Guild with more detailed steps.
  • Sunnysider No worries! I'll also add that:

    AppBuilder 5 is just a single data field that shows one value
    AppBuilder 5+ allows you to have 2 to 6 formulas on the same page

    If you need to use more complex formulas or just validate your formula, you can the web app which converts formuals to code. The complete manual is also on the same site: https://ciq-appbuilder.blogspot.com/p/5plus.html

    In addition to converting formulas to code, the web app will also validate your formulas for syntax errors, etc., so it's still worth using even if you don't need code or can't use it (older device).

    Good luck with your marathon!
  • I'll admit that AppBuilder is pretty problematic in that if your formula is too complex, it will just crash either immediately or when you press START, due to initializing too slowly or running out of memory (not an issue with your watch). The web app solves the first problem, and having a newer watch solves the second one. You still probably can't use code nearly as complicated as was possible on Suunto, where this stuff was built-in.

    I happen to think it does reduce the barrier of entry to "coding" on Garmin watches, although in a very limited kind of way. If you know your formula but don't have to time to code it, it can help.