Function implementing a constant mean suitable for use with :py:class:`MeanFunction`.
341586
def constant(X, n, mu, hyper_deriv=None):
    
    if (n == 0).all():
        if hyper_deriv is not None:
            return scipy.ones(X.shape[0])
        else:
            return mu * scipy.ones(X.shape[0])
    else:
        return scipy.zeros(X.shape[0])
510007
function(x, mean, std) {
        return 0.5 * (1 + erf((x - mean) / Math.sqrt(2 * std * std)));
    }
1214683
def Mean(self):
        
        mu = 0.0
        for x, p in self.d.iteritems():
            mu += p * x
        return mu
1340340
def count_below_mean(x):
    
    m = np.mean(x)
    return np.where(x < m)[0].size
795985
def mean_se(series, mult=1):
    
    m = np.mean(series)
    se = mult * np.sqrt(np.var(series) / len(series))
    return pd.DataFrame({'y': [m],
                         'ymin': m-se,
                         'ymax': m+se})
762433
def stdev(x):
    
    """
    from math import sqrt
    n = len(x)
    mean = sum(x) / float(n)
    std = sqrt(sum((a - mean)**2 for a in x) / float(n - 1))
    return std
637307
def predictive_mean(self, mu, variance, Y_metadata=None):
        
        #conditional_mean: the edpected value of y given some f, under this likelihood
        fmin = -np.inf
        fmax = np.inf
        def int_mean(f,m,v):
            exponent = -(0.5/v)*np.square(f - m)
            #If exponent is under -30 then exp(exponent) will be very small, so don't exp it!)
            #If p is zero then conditional_mean will overflow
            assert v.all() > 0
            p = safe_exp(exponent)

            #If p is zero then conditional_variance will overflow
            if p < 1e-10:
                return 0.
            else:
                return self.conditional_mean(f)*p
        scaled_mean = [quad(int_mean, fmin, fmax,args=(mj,s2j))[0] for mj,s2j in zip(mu,variance)]
        mean = np.array(scaled_mean)[:,None] / np.sqrt(2*np.pi*(variance))
        return mean
844266
def p_constant_def(t):
    """"""
    global name_dict
    id = t[2]
    value = t[4]
    lineno = t.lineno(1)
    if id_unique(id, 'constant', lineno):
        name_dict[id] = const_info(id, value, lineno)
1010597
def metarate(self, func, name='values'):
        
        setattr(func, name, self.values)
        return func
678107
def make_constants(builtin_only=False, stoplist=[], verbose=False):
    
    if type(builtin_only) == type(make_constants):
        raise ValueError("The make_constants decorator must have arguments.")
    return lambda f: _make_constants(f, builtin_only, stoplist, verbose)
55538
def mean(l, ignore_nan=False, empty=0):
    
    l = iter(l)
    if ignore_nan:
        l = ifilterfalse(np.isnan, l)
    try:
        n = 1
        acc = next(l)
    except StopIteration:
        if empty == 'raise':
            raise ValueError('Empty mean')
        return empty
    for n, v in enumerate(l, 2):
        acc += v
    if n == 1:
        return acc
    return acc / n
514676
def _calc_dic(self):
        """"""

        # Find mean deviance
        mean_deviance = np.mean(self.db.trace('deviance')(), axis=0)

        # Set values of all parameters to their mean
        for stochastic in self.stochastics:

            # Calculate mean of paramter
            try:
                mean_value = np.mean(
                    self.db.trace(
                        stochastic.__name__)(
                    ),
                    axis=0)

                # Set current value to mean
                stochastic.value = mean_value

            except KeyError:
                print_(
                    "No trace available for %s. DIC value may not be valid." %
                    stochastic.__name__)
            except TypeError:
                print_(
                    "Not able to calculate DIC: invalid stochastic %s" %
                    stochastic.__name__)
                return None

        # Return twice deviance minus deviance at means
        return 2 * mean_deviance - self.deviance
531069
def mean(data):
    
    if iter(data) is data:
        data = list(data)
    n = len(data)
    if n < 1:
        raise StatisticsError('mean requires at least one data point')
    return sum(data) / n
450498
function mean( out, x ) {
	var len = x.length,
		i;
	if ( out.length !== len ) {
		throw new Error( 'mean()::invalid input arguments. Input and output matrices must be the same length.' );
	}
	for ( i = 0; i < len; i++ ) {
		out.data[ i ] = MEAN( x.data[ i ] );
	}
	return out;
}
1003662
def SpiceUDFUNS(f):
    

    @functools.wraps(f)
    def wrapping_udfuns(x, value):
        result = f(x)
        value[0] = c_double(result)

    return UDFUNS(wrapping_udfuns)
1085985
def _compute_mean(self, C, mag, r):
        
        mean = (C['c1'] +
                self._compute_term1(C, mag) +
                self._compute_term2(C, mag, r))
        return mean
862618
def set_mean(self, col, row, mean):
        
        javabridge.call(self.jobject, "setMean", "(IID)V", col, row, mean)