# Euclidean Distance Algorithm in PHP

## Recommended Posts

and I've clarified a few things with my friend.

1. The input from the project will be coming from a mobile app which will be using a qr code. The qr code contains the Room Number and the 2 Access Points for each room. When a user scans the qr code it will pass that info to the web app that has the algorithm and verify what room he/she is in the access point that was 'scanned'.

2. For the testing of the project we decided to use two rooms of the building of our alma mater and the access points were already defined based on tests:

Room 413 has Access Point 1 that have the values of -67 dBm to -89 dBm and Access Point 2 that have the values of -40 dbm to -57 dBm while
Room 415 has Access Point 1 that have the values of -30 dBm to -46 dBm and Access Point 2 that have the values of -75 dBm to -100 dBm

3. I already inputted the values and the rooms I've mentioned above in mysql to verify if the input from the qr code that was scanned it correct. but sadly we are stuck with the algorithm itself.

##### Share on other sites

And what's the question?

##### Share on other sites

The algorithm is not difficult to implement in PHP but it seems the problem (for me) is what values to use. Between what values are you looking to test similarity? Point 1 and 2 of room 413 or point 1 of rooms 413 and 415? Each point can have only 1 value, not a range of values.

##### Share on other sites

@requinix We just need help with the algorithm itself. and how to use the values that were mentioned above.

@gw1500se Room 413 and 415 will be tested independently. This was supposed to be implemented on the whole building but for now only 2 rooms will be used first. And AP 1 and 2 for each room will also be tested. (I apologize in advance if I answered your question differently, English is not my main language)

##### Share on other sites

The Euclidean distance formula is simple, but with logarithmic scales it'll be weird.

What you haven't done yet is give a description of what you want to do. Saying "I have these numbers and I want to use the 'Euclidean Distance Algorithm' with them" doesn't actually say anything. What are you trying to get out of this? Why are you calculating a "distance" with field strength measurements?

##### Share on other sites

@requinix The project is about attendance tracking through wifi fingerprinting based on a published paper that I posted in my original question months ago.
The project aims to track the log in and log out time of the faculty members of a school and determine the accuracy of location estimation using QR code and WIFI RSS Fingerprinting.

##### Share on other sites

Not sure how the QR code is supposed to help, but if you want to determine approximate location based on signal strengths, convert those signal strengths into distances from the AP (it's not enough to know -67 dBm but you have to know where that measurement happened), then apply standard triangulation math (which also requires knowing the location of the APs themselves).

In other words, get some real world numbers, do the math on paper until you get the right answers, then translate that math into code.

##### Share on other sites

@requinixI think my friend has already done that part. that's why the code is the only thing missing. since the algorithm is already available from the published paper.

Edited by -franciskane-
##### Share on other sites

1. You still haven't asked a specific question. As in, written a sentence that ends in a question mark. You've said things about algorithms and papers and Euclidean this and Euclidean that, but never asked a question.
2. "Euclidean distance" is a highly Google-able phrase that leads to a very simple (you probably already know what it is, even if you aren't aware of it yet) equation.
3. You're reading through a paper that involves... well, it's not that it has a lot of math in it, but that it's not casual reading material. Honestly, a lot of it is quite obvious if you give it a minute - what's "new" is the concept of using multiple measurements as a way of reducing errors. It's basically statistical regression.

So how about you do everyone a favor and ask a specific question that demonstrates either (a) you do not have the necessary background information about how the math is supposed to work, and are looking for an explanation of it, or (b) you do have the necessary background information and are having a hard time with one or more specific aspects of translating that information into code.

Above all, I want to see a sentence with a question mark. Bonus points for stating what Euclidean distance is, and more bonus points for posting the code you've written so far.

##### Share on other sites

Just for the record here is the algorithm in PHP.

`\$d=sqrt(pow(\$q2-\$1q1,2)+pow(\$q4-\$q3,2)+pow(\$q6-\$q5,)+...);`

What you use for those values and how many is up to you.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×

• #### Activity

• Chat
×
• Create New...