import sum from 'avvo_ui/util/sum'

import distanceMoved from 'avvo_ui/util/distance-moved'

export default function (coords) {
  const size = coords.length
  if (size < 3) return Infinity

  const distances = []

  for (let i = 1; i < size; ++i) {
    distances.push(distanceMoved(coords[i - 1], coords[i]))
  }

  return sum(distances) / (size - 1)
}
