distance

Signed distance matrix in R

江枫思渺然 提交于 2019-12-24 10:50:01
问题 [Note, I wrote out this question, then found an answer. I thought maybe someone else would like to know it, so I'm posting the answer just in case. I'm not sure if this is the "done thing"]. Suppose I want the signed distance matrix of a vector, i.e. the distance's aren't always positive, but can be negative. You can't use dist() because it returns absolute values. 回答1: Here's another approach, which is much faster and needs less memory: y <- sample (1 : 4) distmat <- outer (y, y, `-`) yields

Why don't we include 0 matches while calculating jaccard distance between binary numbers?

馋奶兔 提交于 2019-12-24 09:26:02
问题 I am working on a program based on Jaccard Distance, and I need to calculate the Jaccard Distance between two binary bit vectors. I came across the following on the net: If p1 = 10111 and p2 = 10011, The total number of each combination attributes for p1 and p2: M11 = total number of attributes where p1 & p2 have a value 1, M01 = total number of attributes where p1 has a value 0 & p2 has a value 1, M10 = total number of attributes where p1 has a value 1 & p2 has a value 0, M00 = total number

Jaccard's distance matrix with tensorflow

做~自己de王妃 提交于 2019-12-24 08:08:43
问题 I would like to compute a distance matrix using the Jaccard distance. And do so as fast as possible. I used to use scikit-learn's pairwise_distances function. But scikit-learn doesn't plan to support GPU, and there's even a known bug that makes the function slower when run in parallel. My only constraint is that the resulting distance matrix can then be fed to scikit-learn's DBSCAN clustering algorithm. I was thinking about implementing the computation with tensorflow but couldn't find a nice

How to calculate geographic distance between two points along a line in R?

女生的网名这么多〃 提交于 2019-12-24 07:26:12
问题 Inputs I have two shapefiles that I Import into R, so that I end up with. A spatiallinesdataframe containing bus routes. A spatialpointsdataframe containing bus stops. Plotting a given route with its stops looks like this. Sample Data This link includes two shapefiles to download as a zip with a sample two routes. Target My aim is to calculate the geographic distance in meters between every pair of stops: Stop 1 to Stop 2, Stop 2 to Stop 3, etc. across the length of the underlying bus route.

Java GeoTools: how to find distance from a point to closest polygon in shape file

╄→尐↘猪︶ㄣ 提交于 2019-12-24 06:49:23
问题 So I have a shp-file containing a bunch of polygons. In this case, a polygon is a body of in-land water (like lakes and that kind of stuff). My system is tracking a moving object, so in order to determine what this object is, I would like to see if this object is in water or on land AND how far it is to NEAREST shore (yes, both if it's in or out of water). I will take a sample point from the object once in a while and test it. The system is written in Java, and I have imported GeoTools

Calculating great circle distance in r programming with high data resolution

放肆的年华 提交于 2019-12-24 05:50:10
问题 I'm new to R programming but I'm calculating the great circle distance flown by a long haul airliner and I've tried rdist.earth() from the Fields package, soDistsN1() from the sp package and other commands. Plus I've pretty much exhausted Google in my search. It's easy to do this in Matlab but I can't seem to find a way in R. The problem is when I increase the data resolution (amount of waypoints calculated) my total distance goes haywire. I'm guessing it is because of how I summarize the

Spearman's footrule distance with base R

£可爱£侵袭症+ 提交于 2019-12-24 00:29:29
问题 Given two permutations: v1 [1] 4 3 1 5 2 v2 [1] 2 3 4 5 1 How do you compute the Spearman's footrule distance (total displacement of all elements) with base R? (flexible for any two permutations of size n ) For example, for these two vectors, it's as follows: 1 is moved 2 places from v1 to v2 2 is moved 4 places from v1 to v2 3 is moved 0 places from v1 to v2 4 is moved 2 places from v1 to v2 5 is moved 0 places from v1 to v2 So the total distance would be: 2+4+0+2+0 = 8 回答1: Here is a method

Calculating geographic distance between a list of coordinates (lat, lng)

南楼画角 提交于 2019-12-23 18:19:12
问题 I'm writing a flask application, using some data extracted from a GPS sensor. I am able to draw the route on a Map and I want to calculate the distance the GPS sensor traveled. One way could be to just get the start and end coordinates, however due to the way the sensor travels this is quite inaccurate. Therefore I do sampling of each 50 sensor samples. If the real sensor sample size was 1000 I will now have 20 samples (by extracting each 50 sample). Now I want to be able to put my list of

Django TastyPie Geo Distance Lookups

牧云@^-^@ 提交于 2019-12-23 17:28:04
问题 I'm using TastyPie for Geo-distance lookups. That is a bit difficult, because oficially its not supported by TastyPie. On Github (https://gist.github.com/1067176) I found the following code-sample: def apply_sorting(self, objects, options=None): if options and "longitude" in options and "latitude" in options: return objects.distance(Point(float(options['latitude']), float(options['longitude']))).order_by('distance') return super(UserLocationResource, self).apply_sorting(objects, options) It

Tanimoto coefficient distance measure

北战南征 提交于 2019-12-23 11:39:48
问题 Can two objects have identical cosine and Tanimoto coefficient distance measure, where Tanimoto distance measure, d(x,y) = x.y / (|x|*|x|) + (|y|*|y|)- x*y and cosine measure, d(x,y) = x.y /(|x|* |x|) * (|y| *|y|) 回答1: The Tanimoto similarity coefficient (which is not a true distance measure) is defined by d(x,y) = x.y / ((|x|*|x|) + (|y|*|y|)- x.y) for bit vectors x and y. Now compare that with the cosine similarity coefficent, d(x,y) = x.y / (|x| * |y|) The denominators differ by a x.y term