Returns adjusted TIP p-values for a particular `alpha`.

    (see :func:`tip_zscores` for more info)

    :param a: NumPy array, where each row is the signal for a feature
    :param alpha: False discovery rate
168367
def tip_fdr(a, alpha=0.05):
    
    zscores = tip_zscores(a)
    pvals = stats.norm.pdf(zscores)
    rejected, fdrs = fdrcorrection(pvals)
    return fdrs
706217
def cublasDger(handle, m, n, alpha, x, incx, y, incy, A, lda):
    
    
    status = _libcublas.cublasDger_v2(handle,
                                      m, n,
                                      ctypes.byref(ctypes.c_double(alpha)),
                                      int(x), incx,
                                      int(y), incy, int(A), lda)
    cublasCheckStatus(status)
693558
def get_precision(self):
        
        assert self.classifier is not None, 'not calibrated'
        arr = np.zeros((self._som.nrows, self._som.ncols))
        for ij, (lbl, p) in self.classifier.items():
            arr[ij] = p
        return arr
1335584
def get_alpha_or_number(number, template):
    
    match = re.match(r".*\{alpha:(\d+a\d+d)\}$", template.strip())
    if match and match.groups():
        format = match.groups()[0]
        return to_alpha(number, format)
    return number
644967
def int_to_alpha(n, upper=True):
    ""
    casenum = 65 if upper else 97
    label = ''
    count= 0
    if n == 0: return str(chr(n + casenum))
    while n >= 0:
        mod, div = n % 26, n
        for _ in range(count):
            div //= 26
        div %= 26
        if count == 0:
            val = mod
        else:
            val = div
        label += str(chr(val + casenum))
        count += 1
        n -= 26**count
    return label[::-1]
203517
def median_interval(data, alpha=_alpha):
    
    q = [100*alpha/2., 50, 100*(1-alpha/2.)]
    lo,med,hi = np.percentile(data,q)
    return interval(med,lo,hi)
92708
def M(self, t, tips=None, gaps=None):
        """"""
        assert isinstance(t, float) and t > 0, "Invalid t: {0}".format(t)
        with scipy.errstate(under='ignore'): # don't worry if some values 0
            if ('expD', t) not in self._cached:
                self._cached[('expD', t)] = scipy.exp(self.D * self.mu * t)
            expD = self._cached[('expD', t)]
            if tips is None:
                # swap axes to broadcast multiply D as diagonal matrix
                M = broadcastMatrixMultiply((self.A.swapaxes(0, 1) *
                        expD).swapaxes(1, 0), self.Ainv)
            else:
                M = broadcastMatrixVectorMultiply((self.A.swapaxes(0, 1)
                        * expD).swapaxes(1, 0), broadcastGetCols(
                        self.Ainv, tips))
                if gaps is not None:
                    M[gaps] = scipy.ones(N_CODON, dtype='float')
        #if M.min() < -0.01:
        #    warnings.warn("Large negative value in M(t) being set to 0. "
        #            "Value is {0}, t is {1}".format(M.min(), t))
        M[M < 0] = 0.0
        return M
60484
def estimate_params(self,burn=None,clip=10.0,alpha=0.32):
        
        mle = self.get_mle()
        out = odict()
        for param in mle.keys():
            out[param] = self.estimate(param,burn=burn,clip=clip,alpha=alpha)
        return out
823940
function ema(close, n = 5) {
    let len = close.length
    let result = []
    if (len === 0 || n <= 0) {
        return result
    }
    let alpha = 2 / (n + 1)
    let avg = close[0]
    result.push(avg)
    for (let i = 1; i < len; i++) {
        avg = alpha * close[i] + (1 - alpha) * avg
        result.push(avg)
    }
    return result
}
1164458
def median_interval(self, name, alpha=_alpha, **kwargs):
        
        data = self.get(name,**kwargs)
        return median_interval(data,alpha)
675731
def bayesianUpperLimit(self, alpha, steps=1.e5, plot=False):
        
        x_dense, y_dense = self.densify()
        y_dense -= np.max(y_dense) # Numeric stability
        f = scipy.interpolate.interp1d(x_dense, y_dense, kind='linear')
        x = np.linspace(0., np.max(x_dense), steps)
        pdf = np.exp(f(x) / 2.)
        cut = (pdf / np.max(pdf)) > 1.e-10
        x = x[cut]
        pdf = pdf[cut]
        #pdf /= pdf[0]
        #forbidden = np.nonzero(pdf < 1.e-10)[0]
        #if len(forbidden) > 0:
        #    index = forbidden[0] # Numeric stability
        #    x = x[0: index]
        #    pdf = pdf[0: index]
        cdf = np.cumsum(pdf)
        cdf /= cdf[-1]
        cdf_reflect = scipy.interpolate.interp1d(cdf, x)

        return cdf_reflect(alpha)
820740
def field_alpha_histogram(
        self, name, n_bins=10, include_queries=True, **query_dict
    ):
        
        bin_list = []
        q_bin = []
        try:
            # get total number of values for the field
            # TODO: this is a slow mechanism to retrieve the number of distinct values
            # Need to replace this with something more efficient.
            # Can probably replace with a range of alpha chars - need to check on
            # case sensitivity
            param_dict = query_dict.copy()
            f_vals = self.get_field_values(name, maxvalues=-1, **param_dict)
            n_values = len(f_vals[name]) // 2
            if n_values < n_bins:
                n_bins = n_values
            if n_values == n_bins:
                # Use equivalence instead of range queries to retrieve the
                # values
                for i in range(n_bins):
                    a_bin = [f_vals[name][i * 2], f_vals[name][i * 2], 0]
                    bin_q = '{}:{}'.format(
                        name, self._prepare_query_term(name, a_bin[0])
                    )
                    q_bin.append(bin_q)
                    bin_list.append(a_bin)
            else:
                delta = n_values / n_bins
                if delta == 1:
                    # Use equivalence queries, except the last one which includes the
                    # remainder of terms
                    for i in range(n_bins - 1):
                        a_bin = [f_vals[name][i * 2], f_vals[name][i * 2], 0]
                        bin_q = '{}:{}'.format(
                            name, self._prepare_query_term(name, a_bin[0])
                        )
                        q_bin.append(bin_q)
                        bin_list.append(a_bin)
                    term = f_vals[name][(n_bins - 1) * 2]
                    a_bin = [term, f_vals[name][((n_values - 1) * 2)], 0]
                    bin_q = '{}:[{} TO *]'.format(
                        name, self._prepare_query_term(name, term)
                    )
                    q_bin.append(bin_q)
                    bin_list.append(a_bin)
                else:
                    # Use range for all terms
                    # now need to page through all the values and get those at
                    # the edges
                    c_offset = 0.0
                    delta = float(n_values) / float(n_bins)
                    for i in range(n_bins):
                        idx_l = int(c_offset) * 2
                        idx_u = (int(c_offset + delta) * 2) - 2
                        a_bin = [f_vals[name][idx_l], f_vals[name][idx_u], 0]
                        # logger.info(str(a_bin))
                        try:
                            if i == 0:
                                bin_q = '{}:[* TO {}]'.format(
                                    name, self._prepare_query_term(name, a_bin[1])
                                )
                            elif i == n_bins - 1:
                                bin_q = '{}:[{} TO *]'.format(
                                    name, self._prepare_query_term(name, a_bin[0])
                                )
                            else:
                                bin_q = '{}:[{} TO {}]'.format(
                                    name,
                                    self._prepare_query_term(name, a_bin[0]),
                                    self._prepare_query_term(name, a_bin[1]),
                                )
                        except Exception:
                            self._log.exception('Exception:')
                            raise
                        q_bin.append(bin_q)
                        bin_list.append(a_bin)
                        c_offset = c_offset + delta
            # now execute the facet query request
            param_dict = query_dict.copy()
            param_dict.update(
                {
                    'rows': '0',
                    'facet': 'true',
                    'facet.field': name,
                    'facet.limit': '1',
                    'facet.mincount': 1,
                    'facet.query': [sq.encode('utf-8') for sq in q_bin],
                }
            )
            resp_dict = self._post_query(**param_dict)
            for i in range(len(bin_list)):
                v = resp_dict['facet_counts']['facet_queries'][q_bin[i]]
                bin_list[i][2] = v
                if include_queries:
                    bin_list[i].append(q_bin[i])
        except Exception:
            self._log.exception('Exception')
            raise
        return bin_list
277673
def has_hints(self):
        
        for acc in ["low", "normal", "high"]:
            try:
                if self.hint_for_accuracy(acc) is None:
                    return False
            except KeyError:
                return False
        return True
552652
def MarginalBeta(self, i):
        
        alpha0 = self.params.sum()
        alpha = self.params[i]
        return Beta(alpha, alpha0 - alpha)
55674
def alpha(self):
        
        return round(
            float(
                self.calc_alpha(
                    self.annualize_return,
                    self.benchmark_annualize_return,
                    self.beta,
                    0.05
                )
            ),
            2
        )
736270
def get_p_vals(self, X):
		'''
		

		'''
		z_scores = self.get_scores(X[:, 0], X[:, 1])
		return norm.cdf(z_scores)
118723
def _get_asym_alpha(self,a,b):
        
        
        # just  use AL0
        try:
            a = a[2:4]
        except IndexError:
            a = a[:2]
            
        # sum counts in alpha detectors
        asum = np.sum(a,axis=0)
        
        # sum counts in beta detectors
        bsum = np.sum(b,axis=0)
        
        # check for dividing by zero 
        asum[asum == 0] = np.nan
        bsum[bsum == 0] = np.nan
        
        # asym calcs
        asym = asum/bsum
        
        # errors
        dasym = asym*np.sqrt(1/asum + 1/bsum)
        
        return [asym,dasym]