parameters: (self, dim, size=1, random_state=None)
return_statement: return H
docstring: Draw random samples from SO(N).
  
          Parameters
          ----------
          dim : integer
              Dimension of rotation space (N).
          size : integer, optional
              Number of samples to draw (default 1).
  
          Returns
          -------
          rvs : ndarray or scalar
              Random size N-dimensional matrices, dimension (size, dim, dim)
docstring_summary: Draw random samples from SO(N).
docstring_tokens: Draw random samples from SO ( N ) .
function: def rvs(self, dim, size=1, random_state=None):
          """
          Draw random samples from SO(N).
  
          Parameters
          ----------
          dim : integer
              Dimension of rotation space (N).
          size : integer, optional
              Number of samples to draw (default 1).
  
          Returns
          -------
          rvs : ndarray or scalar
              Random size N-dimensional matrices, dimension (size, dim, dim)
  
          """
          random_state = self._get_random_state(random_state)
  
          size = int(size)
          if size > 1:
              return np.array([self.rvs(dim, size=1, random_state=random_state)
                               for i in range(size)])
  
          dim = self._process_parameters(dim)
  
          H = np.eye(dim)
          D = np.empty((dim,))
          for n in range(dim-1):
              x = random_state.normal(size=(dim-n,))
              D[n] = np.sign(x[0]) if x[0] != 0 else 1
              x[0] += D[n]*np.sqrt((x*x).sum())
              # Householder transformation
              Hx = (np.eye(dim-n) - 2.*np.outer(x, x)/(x*x).sum())
              mat = np.eye(dim)
              mat[n:, n:] = Hx
              H = np.dot(H, mat)
          D[-1] = (-1)**(dim-1)*D[:-1].prod()
          # Equivalent to np.dot(np.diag(D), H) but faster, apparently
          H = (D*H.T).T
          return H
function_tokens: def rvs ( self , dim , size = 1 , random_state = None ) : random_state = self . _get_random_state ( random_state ) size = int ( size ) if size > 1 : return np . array ( [ self . rvs ( dim , size = 1 , random_state = random_state ) for i in range ( size ) ] ) dim = self . _process_parameters ( dim ) H = np . eye ( dim ) D = np . empty ( ( dim , ) ) for n in range ( dim - 1 ) : x = random_state . normal ( size = ( dim - n , ) ) D [ n ] = np . sign ( x [ 0 ] ) if x [ 0 ] != 0 else 1 x [ 0 ] += D [ n ] * np . sqrt ( ( x * x ) . sum ( ) ) # Householder transformation Hx = ( np . eye ( dim - n ) - 2. * np . outer ( x , x ) / ( x * x ) . sum ( ) ) mat = np . eye ( dim ) mat [ n : , n : ] = Hx H = np . dot ( H , mat ) D [ - 1 ] = ( - 1 ) ** ( dim - 1 ) * D [ : - 1 ] . prod ( ) # Equivalent to np.dot(np.diag(D), H) but faster, apparently H = ( D * H . T ) . T return H