def spherical(h, r, sill, nugget=0):
    """
    Spherical variogram model function. Calculates the
    dependent variable for a given lag (h). The nugget (b) defaults to be 0.
    
    Parameters
    ----------
    h : float
        The lag at which the dependent variable is calculated at.
    r : float
        Effective range of autocorrelation.
    sill : float
        The sill of the variogram, where the semivariance begins to saturate. 
    nugget : float, default=0
        The nugget of the variogram. This is the value of independent
        variable at the distance of zero. 
    Returns
    -------
    gamma : numpy float
        Coefficients that describe effective range of spatial autocorrelation
    """
    a = r / 1.
    if h <= r:
        return nugget + sill * ((1.5 * (h / a)) - (0.5 * ((h / a) ** 3.0)))
    else:
        return nugget + sill