(p_vec, shape=[1], dtype='float32')
return tf.where(tf.less(dist, p_vec),
                    tf.ones(shape, dtype=dtype),
                    tf.zeros(shape, dtype=dtype))
Generate a binomial distribution based on a vector of probabilities.

    Parameters
    ----------
    p_vec : array
        Probability vector.
    shape : list
        Shape of binomial distribution.

    Returns
    -------
    Tensor
        Binomial distribution.
Generate a binomial distribution based on a vector of probabilities.
Generate a binomial distribution based on a vector of probabilities .
def binomial_vec(p_vec, shape=[1], dtype='float32'):
    """Generate a binomial distribution based on a vector of probabilities.

    Parameters
    ----------
    p_vec : array
        Probability vector.
    shape : list
        Shape of binomial distribution.

    Returns
    -------
    Tensor
        Binomial distribution.
    """
    dist = tf.random_uniform(shape=shape, minval=0, maxval=1, dtype='float32')
    return tf.where(tf.less(dist, p_vec),
                    tf.ones(shape, dtype=dtype),
                    tf.zeros(shape, dtype=dtype))
def binomial_vec ( p_vec , shape = [ 1 ] , dtype = 'float32' ) : dist = tf . random_uniform ( shape = shape , minval = 0 , maxval = 1 , dtype = 'float32' ) return tf . where ( tf . less ( dist , p_vec ) , tf . ones ( shape , dtype = dtype ) , tf . zeros ( shape , dtype = dtype ) )