#NEWLINE# def multinomial( random_state , size = None , n = 1 , pvals = [ 0.5 , 0.5 ] , ndim = None , dtype = 'int64' ) : #NEWLINE# #INDENT# '\n    Sample from one or more multinomial distributions defined by\n    one-dimensional slices in pvals.\n\n    Parameters\n    ----------\n    pvals\n        A tensor of shape "nmulti+(L,)" describing each multinomial\n        distribution.  This tensor must have the property that\n        numpy.allclose(pvals.sum(axis=-1), 1) is true.\n    size\n        A vector of shape information for the output; this can also\n        specify the "nmulti" part of pvals\' shape.  A -1 in the k\'th position\n        from the right means to borrow the k\'th position from the\n        right in nmulti. (See examples below.)\n        Default ``None`` means size=nmulti.\n    n\n        The number of experiments to simulate for each\n        multinomial. This can be a scalar, or tensor, it will be\n        broadcasted to have shape "nmulti".\n    dtype\n        The dtype of the return value (which will represent counts)\n\n    Returns\n    -------\n    tensor\n        Tensor of len(size)+1 dimensions, and shape[-1]==L, with\n        the specified ``dtype``, with the experiment counts. See\n        examples to understand the shape of the return value, which is\n        derived from both size and pvals.shape. In return value rval,\n        "numpy.allclose(rval.sum(axis=-1), n)" will be true.\n\n    Extended Summary\n    ----------------\n    For example, to simulate n experiments from each multinomial in a batch of\n    size B:\n\n        size=None, pvals.shape=(B,L) --> rval.shape=[B,L]\n\n        rval[i,j] is the count of possibility j in the i\'th distribution (row)\n        in pvals.\n\n    Using size:\n\n        size=(1,-1), pvals.shape=(A,B,L)\n        --> rval.shape=[1,B,L], and requires that A==1.\n\n        rval[k,i,j] is the count of possibility j in the distribution specified\n        by pvals[k,i].\n\n    Using size for broadcasting of pvals:\n\n        size=(10, 1, -1), pvals.shape=(A, B, L)\n        --> rval.shape=[10,1,B,L], and requires that A==1.\n\n        rval[l,k,i,j] is the count of possibility j in the\n        distribution specified by pvals[k,i], in the l\'th of 10\n        draws.\n\n    ' #NEWLINE# n = tensor . as_tensor_variable ( n ) #NEWLINE# pvals = tensor . as_tensor_variable ( pvals ) #NEWLINE# tmp = pvals . T [ 0 ] . T #NEWLINE# ( ndim , size , bcast ) = _infer_ndim_bcast ( ndim , size , n , tmp ) #NEWLINE# bcast = ( bcast + ( random_state . type . broadcastable [ ( - 1 ) ] , ) ) #NEWLINE# op = RandomFunction ( multinomial_helper , tensor . TensorType ( dtype = dtype , broadcastable = bcast ) , ndim_added = 1 ) #NEWLINE# return op ( random_state , size , n , pvals )