distance

Python, Pairwise 'distance', need a fast way to do it

人盡茶涼 提交于 2019-12-01 02:09:10
问题 For a side project in my PhD, I engaged in the task of modelling some system in Python. Efficiency wise, my program hits a bottleneck in the following problem, which I'll expose in a Minimal Working Example. I deal with a large number of segments encoded by their 3D beginning and endpoints, so each segment is represented by 6 scalars. I need to calculate a pairwise minimal intersegment distance. The analytical expression of the minimal distance between two segments is found in this source. To

MySQL PHP zip code comparison specifically distance

时光总嘲笑我的痴心妄想 提交于 2019-12-01 01:45:47
I'm trying to figure out what would be the most efficient (with respect to load time) to compare the distance between one zip code (which the user provides) and a whole bunch of other zip codes (there's approximately 200 zip codes right now, but its subject to increase over time). I don't need anything exact just in the ball park. I downloaded a zip code csv file for all of the US, and I've got a function which produces the distance between two zip codes (in radians i believe.) I don't need to display the distance i just need to sort the 200 zip codes with the closest being the first of the

Choose n most evenly spread points across point dataset in R

試著忘記壹切 提交于 2019-12-01 00:02:40
Given a set of points, I am trying to select a subset of n points that are most evenly distributed across this set of points. In other words, I am trying to thin out the dataset while still evenly sampling across space. So far, I have the following, but this approach likely won't do well with larger datasets. Maybe there is a more intelligent way to choose the subset of points in the first place... The following code randomly chooses a subset of the points, and seeks to minimize the distance between the points within this subset and the points outside of this subset. Suggestions appreciated!

MySQL User Defined Function for Latitude Longitude Syntax

别说谁变了你拦得住时间么 提交于 2019-11-30 23:53:20
I have created a MySQL function to determine if a set of latitude and longitude coordinates are within a certain range of another set of latitude and longitude coordinates. However, the function is giving me a syntax error so I cannot test to see if it is working properly. Any help figuring out what is causing the error would be greatly appreciated. The function along with a description of it is written below: It works by having the starting lat/long coordinates passed to the function. The database contains the rows targa, targb, and targc, that contain the latitude, longitude, and range

Choose n most evenly spread points across point dataset in R

血红的双手。 提交于 2019-11-30 18:41:12
问题 Given a set of points, I am trying to select a subset of n points that are most evenly distributed across this set of points. In other words, I am trying to thin out the dataset while still evenly sampling across space. So far, I have the following, but this approach likely won't do well with larger datasets. Maybe there is a more intelligent way to choose the subset of points in the first place... The following code randomly chooses a subset of the points, and seeks to minimize the distance

How can I determine the distance between two sets of latitude/longitude coordinates?

ぃ、小莉子 提交于 2019-11-30 18:37:52
I am trying to write something that will determine the distance between to sets of lat/lon coordinates. I am using the following code which I found on this site : public static double distance (double lat1, double lon1, double lat2, double lon2) { double lat1 = Convert.ToDouble(latitude); double lon1 = Convert.ToDouble(longitude); double lat2 = Convert.ToDouble(destlat); double lon2 = Convert.ToDouble(destlon); double theta = toRadians(lon1-lon2); lat1 = toRadians(lat1); lon1 = toRadians(lon1); lat2 = toRadians(lat2); lon2 = toRadians(lon2); double dist = sin(lat1)*sin(lat2) + cos(lat1)*cos

MySQL User Defined Function for Latitude Longitude Syntax

£可爱£侵袭症+ 提交于 2019-11-30 18:24:44
问题 I have created a MySQL function to determine if a set of latitude and longitude coordinates are within a certain range of another set of latitude and longitude coordinates. However, the function is giving me a syntax error so I cannot test to see if it is working properly. Any help figuring out what is causing the error would be greatly appreciated. The function along with a description of it is written below: It works by having the starting lat/long coordinates passed to the function. The

R cluster with Tanimoto/Jaccard

不问归期 提交于 2019-11-30 17:04:25
Input file is Mydata <- read.table(con <- textConnection(' gene treatment1 treatment2 treatment3 aaa 1 0 1 bbb 1 1 1 ccc 0 0 0 eee 0 1 0 '), header=TRUE) close(con) Mydata is gene treatment1 treatment2 treatment3 1 aaa 1 0 1 2 bbb 1 1 1 3 ccc 0 0 0 4 eee 0 1 0 In order to built cluster, I have done d <- dist(mydata, method = "euclidean") fit <- hclust(d, method="ward") plot(fit) I got the cluster based on "euclidean" distance. In my previous message in stackoverflow How to use R to compute Tanimoto/Jacquard Score as distance matrix I found I can also calculate tanimoto-jacquard distance matrix

SQL Distance Query without Trigonometry

二次信任 提交于 2019-11-30 16:14:21
I have an SQLite database, which does not support trig functions. I would like to sort a set of lat,lng pairs in my table by distance as compared to a second lat,lng pair. I'm familiar with the standard haversine distance formula for sorting lat,lng pairs by distance. In this case I don't care particularly for precision, my points are separated by large distances, so I don't mind rounding off the distances by treating curves as straight lines. My question, is there a generally accepted formula for this kind of query? Remember no trig functions! If your points are within reasonable distance of

distance between android and iphone

烂漫一生 提交于 2019-11-30 15:39:25
I am looking for a way to transmit data when two phones are close by. This needs to be cross platform so I cannot use NFC or iBeacon. I plan on using allJoyn to send information. I would only like to send data to others that are within a few feet of me. Is there any way that I could get an accurate reading of distance on other phones? Or can I get an accurate distance on a master device that could be placed in the room? Shot in the dark answer: If both devices are on the same wireless WiFi network (same subnet), then any devices on same network are "close enough". When on the celluar network