Antialiasing

When antialiasing manually(shading with different intensity on, below and above the pixel), how to calculate the distance between the “true” line and the pixel?