code: def fdr(p_values=None, verbose=0):
      """Returns the FDR associated with each p value
  
      Parameters
      -----------
      p_values : ndarray of shape (n)
          The samples p-value
  
      Returns
      -------
      q : array of shape(n)
          The corresponding fdr values
      """
      p_values = check_p_values(p_values)
      n_samples = p_values.size
      order = p_values.argsort()
      sp_values = p_values[order]
  
      # compute q while in ascending order
      q = np.minimum(
          1, n_samples * sp_values / np.arange(1, n_samples + 1)
      )
      for i in range(n_samples - 1, 0, -1):
          q[i - 1] = min(q[i], q[i - 1])
  
      # reorder the results
      inverse_order = np.arange(n_samples)
      inverse_order[order] = np.arange(n_samples)
      q = q[inverse_order]
  
      if verbose:
          import matplotlib.pyplot as plt
  
          plt.figure()
          plt.xlabel("Input p-value")
          plt.plot(p_values, q, ".")
          plt.ylabel("Associated fdr")
      return q
  
file_path: nipy/nipy/algorithms/statistics/empirical_pvalue.py
imports: import numpy
  import scipy.stats
  from numpy.linalg import pinv
label_desc: Use image node_id 5 for calling a global function with example usage: fdr(p_values, verbose) and returns: q