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: Estimate the proportion, mean and variance of a Gaussian distribution
  for a fraction of the data
  
  Parameters
  ----------
  left: float, optional
      Left cut parameter to prevent fitting non-gaussian data
  right: float, optional
      Right cut parameter to prevent fitting non-gaussian data
  
  Notes
  -----
  This method stores the following attributes:
  
  * mu = mu
  * p0 = min(1, np.exp(lp0))
  * sqsigma: variance of the estimated normal
    distribution
  * sigma: np.sqrt(sqsigma) : standard deviation of the estimated
    normal distribution
docstr_tok: ["Estimate","the","proportion",",","mean","and","variance","of","a","Gaussian","distribution","for","a","fraction","of","the","data","Parameters","--","--","--","--","--","left",":","float",",","optional","Left","cut","parameter","to","prevent","fitting","non-gaussian","data","right",":","float",",","optional","Right","cut","parameter","to","prevent","fitting","non-gaussian","data","Notes","--","--","-","This","method","stores","the","following","attributes",":","*","mu","=","mu","*","p0","=","min","(","1",",","np.exp","(","lp0",")",")","*","sqsigma",":","variance","of","the","estimated","normal","distribution","*","sigma",":","np.sqrt","(","sqsigma",")",":","standard","deviation","of","the","estimated","normal","distribution"]
code: def learn(self, left=0.2, right=0.8):
      """
      Estimate the proportion, mean and variance of a Gaussian distribution
      for a fraction of the data
  
      Parameters
      ----------
      left: float, optional
          Left cut parameter to prevent fitting non-gaussian data
      right: float, optional
          Right cut parameter to prevent fitting non-gaussian data
  
      Notes
      -----
      This method stores the following attributes:
  
      * mu = mu
      * p0 = min(1, np.exp(lp0))
      * sqsigma: variance of the estimated normal
        distribution
      * sigma: np.sqrt(sqsigma) : standard deviation of the estimated
        normal distribution
      """
      # take a central subsample of x
      x = self.x[int(self.n * left) : int(self.n * right)]
  
      # generate the histogram
      step = 3.5 * np.std(self.x) / np.exp(np.log(self.n) / 3)
      bins = max(10, int((self.x.max() - self.x.min()) // step))
      hist, ledge = np.histogram(x, bins=bins)
      step = ledge[1] - ledge[0]
      medge = ledge + 0.5 * step
  
      # remove null bins
      hist = hist[hist > 0].astype(np.float64)
      medge = medge[:-1][hist > 0]  # edges include rightmost outer
  
      # fit the histogram
      dmtx = np.ones((3, len(hist)))
      dmtx[1] = medge
      dmtx[2] = medge**2
      coef = np.dot(np.log(hist), pinv(dmtx))
      sqsigma = -1.0 / (2 * coef[2])
      sqsigma = max(sqsigma, 1.0e-6)
      mu = coef[1] * sqsigma
      lp0 = (
          coef[0]
          - np.log(step * self.n)
          + 0.5 * np.log(2 * np.pi * sqsigma)
          + mu**2 / (2 * sqsigma)
      )
      self.mu = mu
      self.p0 = min(1, np.exp(lp0))
      self.sigma = np.sqrt(sqsigma)
      self.sqsigma = sqsigma
  
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 2 for calling the NormalEmpiricalNull obj's underlying member method code with example usage: obj.learn(left, right) without return types