<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lrt(data, model_full, model_reduced, df=None):
 """ Compare two nested models using a likelihood ratio test Parameters {0} model_full : obj A frozen scipy distribution object representing the full model (more complex model). model_reduced : scipy distribution object A frozen scipy distribution object representing the reduced model (simpler model). df : int The degrees of freedom for the lrt (optional). If none, df is calculated as the difference between the number of parameters in the full and reduced models. Returns ------- tuple G^2 statistic, p-value Notes ----- Parameters of distribution objects must be given as keyword arguments. Ex. ``norm = stats.norm(loc=0, scale=1)`` A p-value < alpha suggests significant evidence for the full (more complex) model. In other words, the null hypothesis is that the reduced model is correct The LRT only applies to nested models. The G^2 statistic and G-test rely on the assumption that the test statistic is approximately chi-squared distributed. This assumption breaks down for small samples sizes. Examples -------- (15.33429080890221, 9.0066719644695982e-05) """


    # Calculate G^2 statistic
    ll_full = nll(data, model_full) * -1
    ll_reduced = nll(data, model_reduced) * -1
    test_stat = 2 * (ll_full - ll_reduced)

    # Set df if necessary
    if not df:
        df =  ( len(model_full.args) + len(model_full.kwds)
              - len(model_reduced.args) - len(model_reduced.kwds) )

    return test_stat, stats.chisqprob(test_stat, df)