def generate_posteriors(trees, indent=4):
    """
    Generates the multinomial distributions for the set of subtrees based on
    the respective category probabilities. The strings are generated using a
    specifiable number of indentation whitespaces.
    """

    posteriors = []
    if len(trees) == 1:
        posteriors.append("{}dat ~ dmulti(pr[1,], trials)".format(
            "".join([" "] * indent)))
    else:
        for t_id, tree in enumerate(trees):
            posteriors.append(
                "{}dat[{},] ~ dmulti(pr[{},], trials[{}])".format(
                    "".join([" "] * indent), t_id + 1, t_id + 1, t_id + 1))

    return posteriors