def binomial_sample(<EOL>ntrials,<EOL>offset,<EOL>G,<EOL>heritability=<NUM_LIT:0.5>,<EOL>causal_variants=None,<EOL>causal_variance=<NUM_LIT:0>,<EOL>random_state=None,<EOL>):
link = LogitLink()<EOL>mean, cov = _mean_cov(<EOL>offset, G, heritability, causal_variants, causal_variance, random_state<EOL>)<EOL>lik = BinomialProdLik(ntrials, link)<EOL>sampler = GGPSampler(lik, mean, cov)<EOL>return sampler.sample(random_state)<EOL>
Binomial likelihood sampling.

    Parameters
    ----------
    random_state : random_state
        Set the initial random state.

    Example
    -------

    .. doctest::

        >>> from glimix_core.random import binomial_sample
        >>> from numpy.random import RandomState
        >>> ntrials = [5, 15]
        >>> offset = 0.5
        >>> G = [[1, -1], [2, 1]]
        >>> binomial_sample(ntrials, offset, G, random_state=RandomState(0))
        array([ 2., 14.])