title: altbeacon - constants for calculating distance
body: <p><br>
  I'm writing my bachelor thesis on indoor navigation using iBeacons. For this i use trilateration to find my position. I've been using the android beacon library, which is now known as the AltBeacon library to detect beacons and calculate the distance. I noticed, that the distances i get aren't that accurate and after some searching here, i came across a post from DavidYoung saying that because most device have different Bluetooth antennas i would have to take that into account when im calculating the distance.<br>
  The AltBeacon library calculates the distance like this (taken from DavidYoungs <a href="https://stackoverflow.com/questions/21338031/radius-networks-ibeacon-ranging-fluctuation/21340147#21340147">post</a>):
      </p>
  
  <pre><code>protected static double calculateAccuracy(int txPower, double rssi) {
    if (rssi == 0) {
      return -1.0; // if we cannot determine accuracy, return -1.
    }
  
    double ratio = rssi*1.0/txPower;
    if (ratio &lt; 1.0) {
      return Math.pow(ratio,10);
    }
    else {
      double accuracy =  (0.89976)*Math.pow(ratio,7.7095) + 0.111;    
      return accuracy;
    }
  }   
  </code></pre>
  
  <p>My question now is:
  how do i calculate these values (0.89976, 7.7095, 0.111) for my Lg G2 with RSSI measurements at certain meter intervals from the beacon?<br>
  I found <a href="http://altbeacon.github.io/android-beacon-library/distance-calcs/nexus5.html" rel="nofollow noreferrer">this</a> as an example for measurement values with the calculated coefficent. </p>
  
  <blockquote>
    <p>Nexus 5 Distance Data</p>
    
    <p>Meters  RSSI<br>
    0.25    -41<br>
    0.5     -43 <br>
    1       -49 <br>
    2       -65 <br>
    3       -58 <br>
    4       -57 <br>
    5       -67<br>
    6       -67 <br>
    7       -77 <br>
    8       -70 <br>
    9       -69 <br>
    10      -75 <br>
    12      -72 <br>
    14      -72 <br>
    16      -78 <br>
    18      -83 <br>
    20      -81 <br>
    25      -81 <br>
    30      -75 <br>
    40      -83<br></p>
    
    <p>Android device:<br>
     version: 4.4.2 <br>
    build_number: LPV79 <br>
    model: Nexus 5<br>
    manufacturer: LGE<br>
    <br>
    Beacon Info:<br> 
    RadBeacon Tag <br>
    Advertisements per second: 10<br>
     Transmit Power: Max<br>
    <br>
    IPhone 5s Average RSSI @1m: -51<br></p>
    
    <p>Distance formula coefficients calculated for these values:<br><br>
    Intercept: 0.1820634    <br>
    Multiplier: 0.8229884  <br>
    Power: 6.6525179<br></p>
  </blockquote>
  
  <p>The term intercept suggests linear regression, but when i put the values into a linear regression calculator it gave me results that were nowhere near those values.<br>
  I hope you can help me and that my question is clear enough :)<br></p>