Parameters
		----------
		pd.Series
		term -> frequency
		Returns
		-------
		PriorFactory
514570
def use_custom_term_frequencies(self, custom_term_frequencies):
		'''
		
		'''
		self.priors += custom_term_frequencies.reindex(self.priors.index).fillna(0)
		return self
342386
def diffPrefsPrior(priorstring):
    """"""
    assert isinstance(priorstring, str)
    prior = priorstring.split(',')
    if len(prior) == 3 and prior[0] == 'invquadratic':
        [c1, c2] = [float(x) for x in prior[1 : ]]
        assert c1 > 0 and c2 > 0, "C1 and C2 must be > 1 for invquadratic prior"
        return ('invquadratic', c1, c2)
    else:
        raise ValueError("Invalid diffprefsprior: {0}".format(priorstring))
1233241
def _hotellings_fourier(self):
        
        sigma_2 = self._catalog_object.sigma**2
        # compute residual
        df = self._df #degrees of freedom
        R = self._A - np.dot(self._X, self._Bhat)
        R = np.matrix(R)
        # residual covariance matrix
        Sigma_R = (R.H*R) * (1./df)
        # noise covariance matrix
        #raise TypeError("fourier domain hypothesis tests not implemented yet")
        Zft = np.matrix(self._basis_object._Z)
        Sigma_S = Zft.H*np.matrix(np.diag(sigma_2))*Zft
        # add covariances (sum of multivariate normals is normal)
        Sigma_Z = np.array(Sigma_R + Sigma_S)

        T_2_list = []
        p_value_list = []
        for i in np.arange(0,self._Bhat.shape[0]):

            Bstar       = self._Bhat[i,np.arange(0,np.shape(self._A)[1])]
            lstar       = float(np.shape(Bstar)[0])
            cx          = self._Cx[i,i]
            Einv        = np.linalg.pinv(Sigma_Z)
            Zs          = Bstar/np.sqrt(cx)
            last_part   = np.array(np.matrix(Zs)*np.matrix(Einv)*np.matrix(Zs).H).real
            T_2         = ((df - lstar + 1.)/(df*lstar))*last_part
            p_value     = 1. - stats.f.cdf(T_2, 2.*lstar, 2.*(df - lstar + 1.))
            p_value_list.append(p_value)
            T_2_list.append(T_2)
        # save pvalue results in a table
        results = [['Comparison','Hotellings T^2', "p-value"]]
        for i in np.arange(0,len(self._col_names)):
            results.append([self._col_names[i], T_2_list[i], p_value_list[i]])
        self._results = results
707142
def _relative_frequency(self, word):
		""""""

		count = self.type_counts.get(word, 0)
		return math.log(count/len(self.type_counts)) if count > 0 else 0
544284
def ref_frequency(self, context):
        
        num_chans = self._manager.spectral_window_table.getcol(MS.NUM_CHAN)
        ref_freqs = self._manager.spectral_window_table.getcol(MS.REF_FREQUENCY)

        data = np.hstack((np.repeat(rf, bs) for bs, rf in zip(num_chans, ref_freqs)))
        return data.reshape(context.shape).astype(context.dtype)
1091552
def get_zeta_i_j_given_separate_counts(self, y_i, y_j):
		'''
		
		'''
		n_i, n_j = y_i.sum(), y_j.sum()
		prior_scale_j = prior_scale_i = 1
		if self._scale_type == 'class-size':
			prior_scale_i = ((n_i) * self._scale * 1. / np.sum(self._priors))
			prior_scale_j = ((n_j) * self._scale * 1. / np.sum(self._priors))
		elif self._scale_type == 'corpus-size':
			prior_scale_j = prior_scale_i = ((n_i + n_j) * self._scale * 1. / np.sum(self._priors))
		elif self._scale_type == 'word':
			prior_scale_j = prior_scale_i = self._scale / np.sum(self._priors)
		elif self._scale_type == 'background-corpus-size':
			prior_scale_j = prior_scale_i = self._scale
		a_wj = (self._priors * prior_scale_j) ** self._prior_power
		a_0j = np.sum(a_wj)
		a_wi = (self._priors * prior_scale_i) ** self._prior_power
		a_0i = np.sum(a_wi)

		delta_i_j = (np.log((y_i + a_wi) / (n_i + a_0i - y_i - a_wi))
		             - np.log((y_j + a_wj) / (n_j + a_0j - y_j - a_wj)))
		var_delta_i_j = (1. / (y_i + a_wi)
		                 + 1. / (n_i + a_0i - y_i - a_wi)
		                 + 1. / (y_j + a_wj)
		                 + 1. / (n_j + a_0j - y_j - a_wj))
		zeta_i_j = delta_i_j / np.sqrt(var_delta_i_j)
		return zeta_i_j
715893
def rolling_vwap(bars, window=200, min_periods=None):
    
    min_periods = window if min_periods is None else min_periods

    typical = ((bars['high'] + bars['low'] + bars['close']) / 3)
    volume = bars['volume']

    left = (volume * typical).rolling(window=window,
                                      min_periods=min_periods).sum()
    right = volume.rolling(window=window, min_periods=min_periods).sum()

    return pd.Series(index=bars.index, data=(left / right)).replace([np.inf, -np.inf], float('NaN')).ffill()
306737
def var(series):
    
    if np.issubdtype(series.dtype, np.number):
        return series.var()
    else:
        return np.nan
684831
def log_prior(self):
        """"""
        if self.priors.size == 0:
            return 0.
        x = self.param_array
        # log densities
        log_p = reduce(lambda a, b: a + b, (p.lnpdf(x[ind]).sum() for p, ind in self.priors.items()), 0)

        #account for the transformation by evaluating the log Jacobian (where things are transformed)
        log_j = 0.
        priored_indexes = np.hstack([i for p, i in self.priors.items()])
        for c,j in self.constraints.items():
            if not isinstance(c, Transformation):continue
            for jj in j:
                if jj in priored_indexes:
                    log_j += c.log_jacobian(x[jj])
        return log_p + log_j
828144
def _set_priors(self, priors=None, fixed=None, random=None,
                    match_derived_names=True):
        '''
        '''

        targets = {}

        if fixed is not None:
            targets.update({name: fixed for name in self.fixed_terms.keys()})

        if random is not None:
            targets.update({name: random for name in self.random_terms.keys()})

        if priors is not None:
            for k, prior in priors.items():
                for name in listify(k):
                    term_names = list(self.terms.keys())
                    msg = "No terms in model match '%s'." % name
                    if name not in term_names:
                        terms = self._match_derived_terms(name)
                        if not match_derived_names or terms is None:
                            raise ValueError(msg)
                        for t in terms:
                            targets[t.name] = prior
                    else:
                        targets[name] = prior

        for name, prior in targets.items():
            self.terms[name].prior = prior
1079844
def probabilistic_inverse_document_frequency(term)
      count = @model.document_count(term).to_f
      log((documents.size - count) / count)
    end
154323
def roc(series, window=14):
    
    res = (series - series.shift(window)) / series.shift(window)
    return pd.Series(index=series.index, data=res)
607297
function(freqSequences) {
        var jvmObject;
        this.logger = Logger.getLogger("PrefixSpanModel_js");
        if(freqSequences instanceof org.apache.spark.mllib.fpm.PrefixSpanModel) {
            jvmObject = freqSequences;
        } else {
            jvmObject = new org.apache.spark.mllib.fpm.PrefixSpanModel(Utils.unwrapObject(freqSequences));
        }


         JavaWrapper.call(this, jvmObject);

    }
1353664
def c_filler(self, frequency):
        '''
        
        '''
        try:
            return np.interp(frequency,
                             self._c_filler['frequency'],
                             self._c_filler['capacitance']
            )
        except:
            pass
        return self._c_filler
682125
def min_freq(self):
        
        i = np.unravel_index(np.argmin(self.bands), self.bands.shape)

        return self.qpoints[i[1]], self.bands[i]
1149520
def forecast(self, horizon, method=ARIMA, frequency=None):
        ''''''
        if len(self.points) <= 1:
            raise ArithmeticError('Cannot run forecast when len(series) <= 1')
        R = LazyImport.rpy2()
        series = LazyImport.numpy().array(self.values)
        if frequency is not None:
            series = R.ts(series, frequency=frequency)
        if method == TimeSeries.ARIMA:
            fit = R.forecast.auto_arima(series)
        elif method == TimeSeries.ETS:
            fit = R.forecast.ets(series)
        else:
            raise ValueError('Unknown forecast() method')
        forecasted = R.forecast.forecast(fit, h=horizon)
        forecast_y = list(forecasted.rx2('mean'))
        interval = self.interval
        last_x = self.points[-1][0]
        forecast_x = [ last_x + x * interval for x in xrange(1, horizon+1) ]
        return TimeSeries(zip(forecast_x, forecast_y))
694568
def lm_ffinal(freqs, damping_times, modes):
    

    f_max = {}
    for lmn in modes:
        l, m, nmodes = int(lmn[0]), int(lmn[1]), int(lmn[2])
        for n in range(nmodes):
            f_max['%d%d%d' %(l,m,n)] = qnm_freq_decay(freqs['%d%d%d' %(l,m,n)],
                                      damping_times['%d%d%d' %(l,m,n)], 1./1000)

    f_final = max(f_max.values())
    if f_final > max_freq:
        f_final = max_freq

    return f_final