class_docstr: Class to compute the empirical null normal fit to the data.
  
  The data which is used to estimate the FDR, assuming a Gaussian null
  from Schwartzmann et al., NeuroImage 44 (2009) 71--82
class_docstr_tok: ["Class","to","compute","the","empirical","null","normal","fit","to","the","data",".","The","data","which","is","used","to","estimate","the","FDR",",","assuming","a","Gaussian","null","from","Schwartzmann","et","al.",",","NeuroImage","44","(","2009",")","71","--","82"]
docstr: Given a threshold theta, find the estimated FDR
  
  Parameters
  ----------
  theta : float or array of shape (n_samples)
      values to test
  
  Returns
  -------
  afp : value of array of shape(n)
docstr_tok: ["Given","a","threshold","theta",",","find","the","estimated","FDR","Parameters","--","--","--","--","--","theta",":","float","or","array","of","shape","(","n_samples",")","values","to","test","Returns","--","--","--","-","afp",":","value","of","array","of","shape","(","n",")"]
code: def fdr(self, theta):
      """Given a threshold theta, find the estimated FDR
  
      Parameters
      ----------
      theta : float or array of shape (n_samples)
          values to test
  
      Returns
      -------
      afp : value of array of shape(n)
      """
      from scipy.stats import norm
  
      self.fdrcurve()
      if np.isscalar(theta):
          if theta > self.sorted_x[-1]:
              return 0
          maj = np.where(self.sorted_x >= theta)[0][0]
          efp = (
              self.p0
              * norm.sf(theta, self.mu, self.sigma)
              * self.n
              / np.sum(self.x >= theta)
          )
          efp = np.maximum(self.sorted_fdr[maj], efp)
      else:
          efp = []
          for th in theta:
              if th > self.sorted_x[-1]:
                  efp.append(0)
                  continue
              maj = self.sorted_fdr[np.where(self.sorted_x >= th)[0][0]]
              efp.append(
                  np.maximum(
                      maj,
                      self.p0
                      * st.norm.sf(th, self.mu, self.sigma)
                      * self.n
                      / np.sum(self.x >= th),
                  )
              )
          efp = np.array(efp)
          #
      efp = np.minimum(efp, 1)
      return efp
  
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 6 for calling the NormalEmpiricalNull obj's underlying member method code with example usage: obj.fdr(theta) and returns: efp, int