public static double calculateAccuracy(final int txPower, final double rssi) {
        if (rssi == 0) {
            return -1.0; // if we cannot determine accuracy, return -1.
        }

        final double ratio = rssi * 1.0 / txPower;
        if (ratio < 1.0) {
            return Math.pow(ratio, 10);
        } else {
            return (0.89976) * Math.pow(ratio, 7.7095) + 0.111;
        }
    }
Calculates the accuracy of an RSSI reading.
<p/>
The code was taken from <a href="http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing" /a>

@param txPower the calibrated TX power of an iBeacon
@param rssi    the RSSI value of the iBeacon
@return the calculated Accuracy
library/src/main/java/dev/alt236/bluetoothlelib/device/beacon/ibeacon/IBeaconUtils.java