def PozyxLS(anchors, W, r2, print_out=False):
    ''' Algorithm used by pozyx (https://www.pozyx.io/Documentation/how_does_positioning_work)

    :param anchors: anchor points
    :param r2: squared distances from anchors to point x.

    :returns: estimated position of point x.
    '''
    N = anchors.shape[0]
    anchors_term = np.sum(np.power(anchors[:-1], 2), axis=1)
    last_term = np.sum(np.power(anchors[-1], 2))
    b = r2[:-1] - anchors_term + last_term - r2[-1]
    A = -2 * (anchors[:-1] - anchors[-1])
    x, res, rank, s = np.linalg.lstsq(A, b)
    return x
Algorithm used by pozyx (https://www.pozyx.io/Documentation/how_does_positioning_work)

    :param anchors: anchor points
    :param r2: squared distances from anchors to point x.

    :returns: estimated position of point x.