code: def generate_data(X, beta, V2, V1):
      """Generate a group of individuals from the provided parameters
  
      Parameters
      ----------
      X: array of shape (n_samples, n_reg),
         the design matrix of the model
      beta: float or array of shape (n_reg, n_tests),
            the associated effects
      V2: float or array of shape (n_tests),
                group variance
      V1: array of shape(n_samples, n_tests),
                 the individual variances
  
      Returns
      -------
      Y: array of shape(n_samples, n_tests)
         the individual data related to the two-level normal model
      """
      # check that the variances are  positive
      if (V1 < 0).any():
          raise ValueError("Variance should be positive")
      Y = np.random.randn(*V1.shape)
      Y *= np.sqrt(V2 + V1)
      if X.ndim == 1:
          X = X[:, np.newaxis]
      if np.isscalar(beta):
          beta = beta * np.ones((X.shape[1], V1.shape[1]))
      if beta.ndim == 1:
          beta = beta[np.newaxis]
  
      Y += np.dot(X, beta)
      return Y
  
file_path: nipy/nipy/algorithms/statistics/mixed_effects_stat.py
imports: import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: generate_data(X, beta, V2, V1) and returns: Y