         if count > 0 {
             self.velocity_mean = total/Double(count)
             self.duration = duration
+        }
+    }
+    
+    /*!
+     * Locates the quantile given an array of sorted values.
+     *
+     * @param quantile
+     * @param values
+     *
+     * @return Double
+     */
+    func locateQuantile(quantile: Double, values: [Double])->Double {
+        let length = values.count
+        let index = quantile * Double(length-1)
+        let boundary = Int(index)
+        let delta = index - Double(boundary)
+        
+        if length == 0 {
+            return 0.0
+        } else if boundary == length-1 {
+            return values[boundary]
+        } else {
+            return (1-delta)*values[boundary] + delta*values[boundary+1]
         }
     }
     

        
        var movingAverage: [Double] = [0, 0, 0, 0, 0]
        var movingAverageTotal = Double(0.0)
        
        if self.points?.count > 0 {
            for p in self.points! {
                if let point = p as? Route {
                    if !started {

                            count++
                        }
                    }
                    
                    
                    // Track the miles.
                    if Int(self.distance_total * self.milesPerMeter) > mileCount {
