Discrete multivariate analysis: theory and practice