Sunday, October 08, 2017

Adjusting Strava KOM speeds for gradient

I’ve been wanting to improve the algorithm behind my Strava segment chooser for some time. Until now it’s been based off the number of riders who’ve attempted the segment and the power output of the KOM. It gave reasonable results but had to ignore any segments whose KOM didn’t have any power data recorded (either from a power meter or estimated based off the rider’s weight and speed). And although more power means more speed, a heavier rider will have to output more power to go at the same speed so the power output isn’t the perfect indicator of how difficult a KOM is to beat.

But using speed also has its problems. 20 mph on a flat segment is generally not going to win any KOMs but 20mph on a 10% gradient may well do. Adjusting the KOM speed for the gradient of the segment has been my aim for a while, but I haven’t had a chance to look at it until now.

Since I now have quite a few segments in my database, I thought it was time to analyse KOM speeds against gradient. I put each segment in a bucket based on its gradient and calculated the average KOM speed. This gave me the following, rather surprising graph.


For gradients between about –2% and 10%, things work as I’d expect. The steeper the gradient, the slower the KOMs are. Beyond that, things get a bit weird. Steeper uphill segments get a little faster and steeper downhill segments get a little slower. I have a few ideas about why this might be (more mountain bike segments, the terror induced by a steep downhill) but nothing definitive.

Whatever the reason, I decided to ignore segments outside –2% to 10%. The graph in this range can be approximated to a straight line so calculating an adjusted speed is fairly easy. I’ve applied this to my segment chooser and the results are, er, much the same as before…

Friday, September 22, 2017

Convert a list to a comma string

It’s nothing special, but I’ve found this useful in the past and probably will again so here for my memory bank is a function that converts a list to a comma string

using System.Collections.Generic;
using System.Text;

namespace Utils
  public static class ListHelper
    public static string ToCommaString<T>(this IEnumerable<T> list, string separator = ", ")
      var builder = new StringBuilder();

      foreach (var t in list)
        if (builder.Length > 0)

      return builder.ToString();

Wednesday, June 28, 2017

Land Registry data for May 2017

I’ve uploaded the latest Land Registry data for England and Wales to my website. My earlier predictions of house price growth going negative appear to be incorrect. Prices continue to go up but at an ever decreasing pace.