Questions tagged [distance-matrix]

A distance matrix is a matrix containing the pairwise distances between the elements of a set. The "distance" may rely on the concept of metric.

The distance matrix for an N-elements set is a NxN matrix in which entry (i,j) contains the distance between items i and j.
The distance might be related to the concept of metric (e.g. Euclidean distance, Mahlanobis distance, and so on) but there are also non-metric distance matrices: an adjacency matrix is an example of such non-metric distance matrices.

174 questions
1
vote
1 answer

How to use use distance matrix to generate natural clusters number?

I have a distance matrix 1609*1609 and the distance range is between 0~1. How to use this matrix to get natural clusters number? I know spss has a TwoStep cluster function that can generate specific number of clusters, but the input should be…
Terence Tien
  • 329
  • 1
  • 3
  • 15
1
vote
2 answers

Generating graph from distance matrix using networkx: inconsistency - Python

I have the following distance matrix: delta = [[ 0. 0.71370845 0.80903791 0.82955157 0.56964983 0. 0. ] [ 0.71370845 0. 0.99583115 1. 0.79563006 0.71370845 0.71370845] [ 0.80903791 0.99583115 …
pceccon
  • 9,379
  • 26
  • 82
  • 158
1
vote
1 answer

Complete distance matrix in MapReduce

I am relatively new to MapReduce and the following problem crossed my mind: how can you calculate in MapReduce a complete (i.e. not sparse) distance matrix? I have a 2D dataset with N instances and I have to evaluate all the possible distances…
AlessioX
  • 3,167
  • 6
  • 24
  • 40
0
votes
1 answer

Calculating a distance matrix based on spatial link distances (aka neighbor distances)

I would like to calculate a distance matrix between the centroids of the polygons in a region considering spatial link distance (aka 'neighbor distances') instead of simple Euclidean distances. Spatial link distance considers the Euclidean distances…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
0
votes
0 answers

Wrong distance matrix from combining point matrix and connection matrix using csv files and numpy library

I need to create a distance(location) matrix from a points matrix and a connection matrix. The problem is I can't get the correct result. The points matrix is: -,x,y a,1,6 b,2,1 c,9,1 d,370,760 and connection…
AlQaholic
  • 1
  • 1
0
votes
0 answers

How to setup a dictionary with ('key 1', 'key 2'): value for a distance matrix imported from excel to Python (Jupyter notebook)?

I am currently working on a vehicle routing problem in Python but I have to set up a dictionary with ('zone x', 'zone y'): numeric distance. I have a lot of zones and for all individual combinations of zones I need a combination for the distance:…
0
votes
0 answers

Problems with distance matrix - R propensity score matching

I have a cohort with about 10 covariates (e.g age, sex, region, index_agent, etc) for which I am trying to match cases to controls in a 1:3 ratio. An additional criteria I have for this match is that my variable called match_time must be greater for…
0
votes
0 answers

Finding Distance and Duration using Google Distance Matrix API in javascript

If someone could please help me figure out my code or at least give me some tips to finishing my code I would really appreciate it. It needs to also display the distance and estimated driving time which I'm having some trouble figuring out how to…
0
votes
0 answers

How to compute distance.matrix for the spatialRF::rf_spatial function

I am using the package spatialRF in R to perform a regression task. From the example provided by the package, the have precomputed the distance.matrix and they use it in the function spatialRF::rf. Here is an example: library(spatialRF) #loading…
Nikos
  • 426
  • 2
  • 10
0
votes
0 answers

Which distance matrix to compute on my absence/presence dataset with many zeros?

I am doing analyses on a dataset of parasite species present or absent in bee samples. I have a matrix with 0/1 for each sample and each parasite species. Since a lot of samples do not have any parasite species, a lot of the rows are all zeroes. I…
0
votes
1 answer

R package vegan stepacross function error

I am trying to use the stepacross function in the vegan package of R. When I do, it throws an error and fails to run the code Error in stepacross(distance.dat, path = "extended") : object 'C_stepacross' not found Anybody know the cause of this or…
theforestecologist
  • 4,667
  • 5
  • 54
  • 91
0
votes
1 answer

Measure the latency in milliseconds between two public DNS servers

Short Introduction: I'm trying to create a distance matrix of the latency between DNS servers in order to predict p2p latencies using matrix factorization. To use the prediction algorithm, I need about 20 DNS servers and the latencies between…
0
votes
1 answer

force-directed graph using qgraph label colors don't match the nodes

I'm using qgraph to plot a network graph from a distance matrix and I can't get the labels to match the colours of the nodes in the graph. My code is as follows: clr <- function(x) { known <- c(`Effluent`="seagreen", `Influent`="brown", `WWTP…
Sushiroll
  • 37
  • 6
0
votes
0 answers

How to convert a distance matrix to a pairwise comparison in Python?

I have a distance matrix and want to convert it to a pairwise comparison. The distance matrix: Distance…
0
votes
0 answers

Google OR tools Capacitated Vehicle Routing Python : How to ensure connectivity between adjacent nodes while creating the distance matrix?

I am uisng OR tools to solve a CVRP problem for mimicing a waste collection system with the below constraints: There can be multiple depots (depot is fixed), from where vehicles can start. The vehicles can start from these depots, pick up waste…
Saugata Paul
  • 59
  • 1
  • 9