Example #1
0
    multinomially distributed integer 1-D array.
    """
    # Check preconditions on arguments
    probs = num.array(probs)
    if len(probs.getshape()) != 1:
        raise ArgumentError, "probs must be 1 dimensional."
        # Compute shape of output
    if type(shape) == type(0): shape = [shape]
    final_shape = shape[:]
    final_shape.append(probs.getshape()[0] + 1)
    x = ranlib.multinomial(trials, probs.astype(num.Float32),
                           num.multiply.reduce(shape))
    # Change its shape to the desire one
    x.setshape(final_shape)
    return x


def poisson(mean, shape=[]):
    """poisson(mean) or poisson(mean, [n, m, ...])

    Returns array of poisson distributed random integers with specifed
    mean.
    """
    return _build_random_array(ranlib.poisson, (mean, ), shape)


from dtest import test

if __name__ == '__main__':
    test()
Example #2
0
File: FFT.py Project: fxia22/ASM_xf
def test():
    import dtest
    return dtest.test()
Example #3
0
def test():
    import dtest
    return dtest.test()
Example #4
0
    In this case, output[i,j,...,:] is a 1-D array containing a
    multinomially distributed integer 1-D array.
    """
    # Check preconditions on arguments
    probs = num.array(probs)
    if len(probs.getshape()) != 1:
        raise ArgumentError, "probs must be 1 dimensional."
        # Compute shape of output
    if type(shape) == type(0): shape = [shape]
    final_shape = shape[:]
    final_shape.append(probs.getshape()[0]+1)
    x = ranlib.multinomial(trials, probs.astype(num.Float32),
                           num.multiply.reduce(shape))
    # Change its shape to the desire one
    x.setshape(final_shape)
    return x

def poisson(mean, shape=[]):
    """poisson(mean) or poisson(mean, [n, m, ...])

    Returns array of poisson distributed random integers with specifed
    mean.
    """
    return _build_random_array(ranlib.poisson, (mean,), shape)


from dtest import test
    
if __name__ == '__main__': 
    test()