import math


def distance(lat1, lng1, lat2, lng2):
    """
        Calculates distance in miles between two lat, long pairs
        Thanks to Philipp Jahoda of StackOverflow.com.
    """
    
    earthRadius = 3958.75
    
    dLat = math.radians(lat2 - lat1)
    dLng = math.radians(lng2 - lng1)
    
    sinDLat = math.sin(dLat / 2)
    sinDLng = math.sin(dLng / 2)
    
    a = (sinDLat ** 2) + (sinDLng ** 2) * math.cos(math.radians(lat1)) * math.cos(math.radians(lat2))
    c = 2 * math.atan2(a ** .5, (1-a) ** .5)
    
    dist = earthRadius * c
    
    return dist