All Questions

Filter by
Sorted by
Tagged with
7 votes
1 answer
802 views

Euclidean distance, different results between Scipy, pure Python, and Java

I was playing around with different implementations of the Euclidean distance metric and I noticed that I get different results for Scipy, pure Python, and Java. Here's how I compute the distance ...
Silas Berger's user avatar
5 votes
5 answers
14k views

Calculating distance between two points in 3D

My assignment is to create main class in which I initialize the value of any point to be at (0,0,0) and to be able to access and mutate all three values (x,y,z) individually. To do this I have used ...
Idan Gelber's user avatar
5 votes
3 answers
39k views

Java methods getting euclidean distance

public class Point { // Placeholders for xcoordinate, ycoordinate, and quadrants int xcoord = 0; int ycoord =0; double distance = 0.0; String quadrant = ("NW"); //moveUp changes the y coordinate ...
user3444564's user avatar
4 votes
0 answers
576 views

Calculate Euclidean distance using Painless in Elasticsearch

I would like to sort results from Elasticsearch according to Euclidean distance between document double array and double array from "params". For now I am using my own solution that calculate this ...
Uladzislau Kaminski's user avatar
3 votes
3 answers
3k views

Euclidean distance returning strange results

im writing a program to compare two images against each other based on color and im using the Euclidean distance algorithm however when i run it and pass in two images i get one distance and then when ...
Roy James Schumacher's user avatar
3 votes
2 answers
3k views

Euclidean distance between two objects

First of all I know what the Euclidean distance is and what it does or calculates between two vectors. But my question is about how to calculate the distance between two class objects for example in ...
Markus G.'s user avatar
  • 1,668
3 votes
2 answers
1k views

squared-euclidean distance with RealVectors in Apache Commons Math

I'm using Apache Commons RealVector and ArrayRealVector classes in Java. I can calculate the euclidean distance between two vectors v1 and v2 as double dist = v1.getDistance(v2); However, I'm ...
COM's user avatar
  • 847
3 votes
0 answers
1k views

How to calculate minimum euclidean distance between two point sets with permutable elements?

I'm working with two sets of points which always have the same number of elements. A0–An and B0–Bn. Both of these sets are non-ordered. [Image 1] I need to calculate minimum possible euclidean ...
ponney's user avatar
  • 31
1 vote
2 answers
103 views

Iteratation through variables of an objects (java)

I have a class Room with the following constructor: public Room (int x, int y, int z, int Stockwerk) { this.x = x; this.y = y; this.z = z; this.Stockwerk = Stockwerk; } In ...
Julian's user avatar
  • 65
1 vote
1 answer
161 views

Is it logical for Manhattan and Euclidean heuristics to check the same nodes?

So I have created an app where I have to find the shortest route from startPos to endPos using the A* algorithm. I have approached this problem with the 2 most common heuristics: 1. Manhattan Distance ...
Chris Costa's user avatar
1 vote
1 answer
164 views

Why does increasing the number of decimal places not affect the computation time of Euclidean distance?

I am trying to microbenchmark a KMeans program. I am focussing on the Euclidean distance at the moment. I thought that (due to the square root, below) increasing the number of decimal places of each ...
user745587's user avatar
1 vote
2 answers
903 views

Issue with OpenCV Warp perspective and euclidean distance

My program uses a C# port of OpenCV to find the largest rectangle in the scene and warps the perspective. It almost works, but has one very annoying bug that I just can't figure out. Using it on a ...
Trench Warfare's user avatar
1 vote
1 answer
249 views

digit categorisation using Euclidean distance

I want to categorise digits which are represented in a 64 dimensional space which gives an 8X8 pixel character image. Each attribute is an integer from 0...16. I have 20 rows of 64 values plus one at ...
Hunor Balint's user avatar
0 votes
1 answer
3k views

Calculating the distance between two squares on a grid - Java

I am creating a game in Java and have a grid of squares that make up the playable area. The player has certain targets and I need to work out how far away the player is from those targets using the x ...
user3407039's user avatar
  • 1,315
0 votes
2 answers
1k views

Calculating distance between two LaB colors Java

I am working on a program where I am trying to find the euclidean distance between two LaB colors. I was wondering if they way I calculate the the distance between the two is correct . Here is what I ...
ProgrammingCuber's user avatar
0 votes
1 answer
11k views

Euclidean Distance between 2 Vectors Implementation

I working through a few exercises from an academic programing book. The task is to implement 2 vectors and calculate the Euclidean distance between thereof. No this is not Home Work, rather self ...
dcrearer's user avatar
  • 2,042
0 votes
1 answer
589 views

calculating euclidean distance of 2 byte arrays java

I have 2 main images and I want to compare a set of other images to them. What I do is computing the byte array of those two images and then compare those 2 with the current image being processed. ...
user3540466's user avatar
0 votes
2 answers
122 views

Finding the smallest number in array list java

So I have some code which is finding the distance between a series of points. One method uses the euclidean distance and is working fine, the other is using Manhattan and I don't know why it isn't ...
Joe McDonald's user avatar
0 votes
1 answer
2k views

Comparing each set of a two-dimensional array to determine largest distance

So I have a set of elements in a 2d array, and I am trying to determine the largest distance between coordinates. I have made a loop to go through each element, but I can't figure out how to only ...
Jane Doe2's user avatar
  • 141
0 votes
1 answer
3k views

Euclidean Distance of two vectors with different length

I have a code for calculating euclidean distance like this : for(int j=0;j<inputdimension;j++){ distance += Math.pow((vector1[j] - vector2.get(j)), 2); } and i've an example of data ...
Idham Choudry's user avatar
0 votes
1 answer
228 views

Combining Euclidian distance by measuring colour and edge distance

Say I have calculated the euclidean distance between two images using colour as a feature and also calculated the distance between the two images using their edges. I want to test to see if combining ...
Bad Dub's user avatar
  • 1,533
0 votes
1 answer
4k views

Calculate chi-squared distance between two image histograms in Java

I have calculated the histograms of two images in Java (Code modified and shortened): for (int posX = 0; posX < image.getWidth(); posX++) { for (int posY = 0; posY < image.getHeight(); posY+...
user3801009's user avatar
0 votes
0 answers
113 views

How can I change my algorithm to get the farthest node for each iteration?

So I am trying to pick out the farthest node for each iteration. I start by randomly picking the first node, then continueing by picking the farthest node from the first one. From there I have two ...
FishyK's user avatar
  • 161
0 votes
1 answer
3k views

Calculate Euclidean Distance Between Two Points Using Constructor

I'm working on an assignment to write a java program which implements a Point data type with the following constructor: Point(double x, double y, double z) and, the following API: double distanceto(...
gizmo.java's user avatar
0 votes
1 answer
584 views

Point2D equals within threshold

I have to write a Point2D class for an assignment and so far I have been able to write the code for all the necessary methods except the equals() methods. I'm having trouble figuring how to write the ...
luckypingvin's user avatar
0 votes
0 answers
1k views

What is the efficient way to calculate Euclidean distance between elements in a n-dimensional large ArrayList with JAVA?

I wanna calculate Euclidean distances between each pairs of elements in a two dimensional array list in JAVA. this two dimensional array list consists of 40000 records in 40 dimensions. I encountered ...
amIllusionist's user avatar
0 votes
0 answers
126 views

Monalisa TSP Tour Length/Distance always wrong

the tour length of www.math.uwaterloo.ca/tsp/data/ml/tour/monalisa_5757191.tour is supposed to be 5757191 yet my code gives a result of 5759929.877458311. Assuming that the claim of being willing to ...
user8578151's user avatar
0 votes
1 answer
149 views

Euclidean distance calculation using apache flink

Apache flink has setup libraries to calculate euclidean distance. I want to use the same API for distance calculation on n-dimensional space. I have two dataset with 3 features. a = {0.1,0.3,0.8} ...
Soumyajit Swain's user avatar
0 votes
1 answer
54 views

I am not getting the actual distance as output from CVS file

I want to calculate the distance between two co-ordinates, which are stored in a CVS file. There are two column mentioned in CVS files for X and Y Co-ordinates respectively. I want to apply ...
Ankita Jiyani's user avatar
0 votes
1 answer
56 views

Find whether car assigned is moving toward customer or moving away customer

Data which available for computation is Driver (lat,lon) x mins customer (lat,lon) x - millisecond Driver (lat,lon) x-1 mins Driver (lat,lon) x-2 mins I have set of location in which i want to ...
Syed Abdul Kather's user avatar
0 votes
1 answer
1k views

Weka Java API - Euclidean Distance: Normalized vs NonNormalized

i want to calculate the normalized euclidean distance between two vectors with length of 5. The simpler way with Apache Math and RealVector does not normalize the distance so I try to use Weka. I have ...
frankenstein's user avatar
0 votes
2 answers
3k views

Calculating the geographic and euclidean distances for TSP in Java

Basically I'm using data from TSPLIB and I have this spec . This is how I calculated the Euclidean distance (according to the above spec): public static double calculateDistance(double x1, double y1, ...
MTA's user avatar
  • 759
0 votes
1 answer
2k views

euclidean algorithm for image comparison

i am going to develop an application for image comparison on java. For this i have choosen euclidean algorithm. This application involves with 2 images. 1. Actual image 2. Part of the actual image. ...
janasainik's user avatar
-1 votes
2 answers
216 views

How to pass an Array as a parameter to a Function/Bifunction?

I need to pass an array as parameter into a BiFunction. Use case : Calculate the Euclidean Distance of 2 coordinates given in an array. coordinate1 and coordinate2 are an array. The below trial, ...
Nilotpal's user avatar
  • 3,419
-1 votes
1 answer
6k views

K-Nearest Neighbor Implementation for Strings (Unstructured data) in Java

I'm looking for implementation for K-Nearest Neighbor algorithm in Java for unstructured data. I found many implementation for numeric data, however how I can implement it and calculate the Euclidean ...
F. Fo's user avatar
  • 123
-4 votes
1 answer
147 views

Incorrect answer of Euclidean Distance Java

I am making a program to calculate the Euclidean Distance of 4 values of Training Data with 4 values of Test Data. For KNN i need to find the Euclidean Distance which i programmed in Java and i am ...
Jee Whizz's user avatar