diff --git a/src/Numerics/Distance.cs b/src/Numerics/Distance.cs
index 3fcfc6a3..b5819f12 100644
--- a/src/Numerics/Distance.cs
+++ b/src/Numerics/Distance.cs
@@ -202,6 +202,36 @@ namespace MathNet.Numerics
return SAD(a, b);
}
+ ///
+ /// Canberra Distance, a weighted version of the L1-norm of the difference.
+ ///
+ public static double Canberra(double[] a, double[] b)
+ {
+ if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
+
+ double sum = 0d;
+ for (var i = 0; i < a.Length; i++)
+ {
+ sum += Math.Abs(a[i] - b[i])/(Math.Abs(a[i]) + Math.Abs(b[i]));
+ }
+ return sum;
+ }
+
+ ///
+ /// Canberra Distance, a weighted version of the L1-norm of the difference.
+ ///
+ public static double Canberra(float[] a, float[] b)
+ {
+ if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
+
+ float sum = 0f;
+ for (var i = 0; i < a.Length; i++)
+ {
+ sum += Math.Abs(a[i] - b[i]) / (Math.Abs(a[i]) + Math.Abs(b[i]));
+ }
+ return sum;
+ }
+
///
/// Chebyshev Distance, i.e. the Infinity-norm of the difference.
///