Formulas for lda