distance

distance between sets even when the sets are unbalanced?

北慕城南 提交于 2019-12-11 04:26:36
问题 I need to find a best distance equation to find the distance between two sets. Distance equations are like euclidean, manhantan or any..I have to find the optimal minimal distance between two entities. Entities are sets with elements(floating values). Sets can be equi number of elements or may vary. for ex: s1={2.1,3.5,2.7,4.9}, s2={4.2,3.1,2.3} How can I find the distance between two such kind of sets ? In my case, each element is indexed to one position...for ex: s1={w,x,y,z}, s2={w,y,z}.

Distance to convexHull

你。 提交于 2019-12-11 03:26:38
问题 I have been searching for a method to compute a distance to a convexHull/polygon such that the distance is positive if the point is within the hull and negative if outside. For example, given a hull and a set of points, can the positive/negative distance be computed? from scipy.spatial import ConvexHull import matplotlib.pyplot as plt import numpy as np # Original points, hull and test points points = np.random.rand(30, 2) # 30 random points in 2-D hull = ConvexHull(points) newpoints = np

Find all point pairs closer than a given maximum distance

家住魔仙堡 提交于 2019-12-11 03:18:00
问题 I want to find (efficiently) all pairs of points that are closer than some distance max_d . My current method, using cdist , is: import numpy as np from scipy.spatial.distance import cdist def close_pairs(X,max_d): d = cdist(X,X) I,J = (d<max_d).nonzero() IJ = np.sort(np.vstack((I,J)), axis=0) # remove diagonal element IJ = IJ[:,np.diff(IJ,axis=0).ravel()<>0] # remove duplicate dt = np.dtype([('i',int),('j',int)]) pairs = np.unique(IJ.T.view(dtype=dt)).view(int).reshape(-1,2) return pairs def

Calculation of distance using lat long in tableau

喜你入骨 提交于 2019-12-11 02:54:16
问题 I have a data file with millions of rows with lat and long columns as 2 of the field in the columns. Would like to ask if there is any ways to calculate the total distance for (e.g. Model X "Index 0 --> Index1 , Index 1--> Index 3" ) using the lat long field Index,Model,lat,long 0,X,1.3539,103.84 1,X,1.3545,103.84 2,Y,1.3839,103.7002 3,X,1.3548,103.84 4,Y,1.3831,103.71 5,Z,1.3139,103.88 Please advice! 回答1: This formula will calculate distance. But to make it work, you'll need to either use

What distance does distanceTo returns?

£可爱£侵袭症+ 提交于 2019-12-11 02:37:00
问题 Does it take into account altitude changes? I mean, if I start in left vertex of this triangle and end in the right upper vertex, does it return distance a or b? double distanceInMetersFloat = initialPosition.distanceTo(finalPosition); In my app, both initialPosition and finalPosition are Location with altitudes (I set them with Google Elevation API). According to Google: Distance is defined using the WGS84 ellipsoid. But you can do it with or without altitudes. 回答1: The altitude is not taken

Why distance matrix api always returning the status “ZERO_RESULTS”?

心不动则不痛 提交于 2019-12-11 02:34:44
问题 I am using the distance matrix api to calculate the distance between one source and multiple destinations. The source latitude / longitude and destination latitudes / longitudes are perfect. Also the route is existing in Google maps between those points. But the api is always returning the status "ZERO_RESULTS". What is the reason for this issue and how it could be solved. The response from distance matrix api is as follows : "rows" : [ { "elements" : [ { "status" : "ZERO_RESULTS" }, {

Calculate the distance between the iPhone and a door, knowing their physical widths

那年仲夏 提交于 2019-12-11 02:27:23
问题 I have this scenario: I know the physical (not only in pixel) size of the screen of the iPhone. Also I know the width of a door. Now, if I have the iPhone camera on (with UIImagePicker or whatever), and I am in the position where the width of the door fits perfectly in the width of the camera, and the iPhone stands perfectly vertical, is it possible to know the distance between the iPhone and the door? 回答1: It would depend on the camera specs which vary between devices. For this reason I

Pairwise Earth Mover Distance across all documents (word2vec representations)

倾然丶 夕夏残阳落幕 提交于 2019-12-11 00:48:07
问题 Is there a library that will take a list of documents and en masse compute the nxn matrix of distances - where the word2vec model is supplied? I can see that genism allows you to do this between two documents - but I need a fast comparison across all docs. like sklearns cosine_similarity. 回答1: The "Word Mover's Distance" (earth-mover's distance applied to groups of word-vectors) is a fairly involved optimization calculation dependent on every word in each document. I'm not aware of any tricks

Finding the smallest distance from any vertex to the border of the graph

↘锁芯ラ 提交于 2019-12-10 21:15:58
问题 So I have triangular mesh approximating a surface. It's like a graph with the following properties: The vertices on the graph border are trivially identifiable. (Number of neighbor vertices > number of containing triangles) You can trivially calculate the distance between any two vertices. (Euclidean distance) For any vertex v , any vertex that is not a neighbor of v must have a greater distance to v than at least one of v 's neighbors. In other words, no non-neighbor vertices may appear

How to calculate possible word subsequences matching a pattern?

南楼画角 提交于 2019-12-10 21:15:58
问题 Suppose I have a sequence: Seq = 'hello my name' and a string: Str = 'hello hello my friend, my awesome name is John, oh my god!' And then I look for matches for my sequence within the string, so I get the "word" index of each match for each word of the sequence in a cell array, so the first element is a cell containing the matches for 'hello', the second element contains the matches for 'my' and the third for 'name'. Match = {[1 2]; %'hello' matches [3 5 11]; %'my' matches [7]} %'name'