I’m a new Julia user, so this might be really obvious, but is there a straight-forward way to generate a pairwise distance matrix from a single vector or column?
In R, it’s pretty straightforward:
for the vector c(2, 4, 6, 8)
dist(c(2, 4, 6, 8))
1 2 3
2 2
3 4 2
4 6 4 2
I’ve played around with Distances.jl, but I’m having trouble getting the function pairwise to work even for simple instances, e.g.:
using Distances
cc = [2, 4, 6, 8];
mm = [1, 3, 5, 7];
pairwise(Euclidean(), cc)
ERROR: MethodError: no method matching pairwise(::Euclidean, ::Array{Int64,1})
pairwise(Euclidean(), cc, mm)
ERROR: MethodError: no method matching pairwise(::Euclidean, ::Array{Int64,1}, ::Array{Int64,1})
The non-pairwise version works. This obviously isn’t what I’m going for, but at least it demonstrates that some of the functionality of Distances.jl is up and running:
euclidean(cc, mm)
2.0