Ejemplo n.º 1
0
def normal(nrows, ncols=1, mean=0.0, std=1.0):
    '''
    Randomly generates a matrix with normally distributed entries.

    normal(nrows, ncols=1, mean=0, std=1)
  
    PURPOSE
    Returns a matrix with typecode 'd' and size nrows by ncols, with
    its entries randomly generated from a normal distribution with mean
    m and standard deviation std.

    ARGUMENTS
    nrows     number of rows

    ncols     number of columns

    mean      approximate mean of the distribution
    
    std       standard deviation of the distribution
    '''

    try:
        from cvxopt import gsl
    except:
        from cvxopt.base import matrix
        from random import gauss
        return matrix([gauss(mean, std) for k in range(nrows * ncols)],
                      (nrows, ncols), 'd')

    return gsl.normal(nrows, ncols, mean, std)
Ejemplo n.º 2
0
def normal(nrows, ncols=1, mean=0.0, std=1.0):
    '''
    Randomly generates a matrix with normally distributed entries.

    normal(nrows, ncols=1, mean=0, std=1)
  
    PURPOSE
    Returns a matrix with typecode 'd' and size nrows by ncols, with
    its entries randomly generated from a normal distribution with mean
    m and standard deviation std.

    ARGUMENTS
    nrows     number of rows

    ncols     number of columns

    mean      approximate mean of the distribution
    std       standard deviation of the distribution
    '''

    try:    
        from cvxopt import gsl
    except:
        from cvxopt.base import matrix
        from random import gauss
        return matrix([gauss(mean, std) for k in range(nrows*ncols)],
                      (nrows,ncols), 'd' )
        
    return gsl.normal(nrows, ncols, mean, std)
Ejemplo n.º 3
0
 def test2(self):
     from cvxopt import gsl
     x = gsl.normal(3,2)
     self.assertTrue(x.size[0] == 3 and x.size[1] == 2)
Ejemplo n.º 4
0
 def test2(self):
     from cvxopt import gsl
     x = gsl.normal(3, 2)
     self.assertTrue(x.size[0] == 3 and x.size[1] == 2)