The standard variance (two pass)
191693
def std_var
      first_pass = @raw.reduce(0) do |acc, elem|
        (elem.score.to_f - mean)**2 + acc
      end
      Math.sqrt(first_pass / (@raw.size - 1))
    end
763014
def Kdiag(self, X):
        """"""
        ret = np.empty(X.shape[0])
        ret[:] = self.variance
        return ret
657416
def stdev(data, xbar=None):
    
    var = variance(data, xbar)
    try:
        return var.sqrt()
    except AttributeError:
        return math.sqrt(var)
444484
def Kdiag(self, X):
        """"""
        K_ff = np.zeros(X.shape[0])
        for i,x in enumerate(X):
            K_ff[i] = self.k_ff(x[0],x[0],self.lengthscale[0])
        return K_ff * self.variances[0]
983557
public double variance(double m1, Object pt1, Object ptSqr1, double m2, Object pt2, Object ptSqr2) {
		// compute the total mass
		double m0 = m1 + m2;
		// compute the new sum
		Object pt0 = newCopy(pt1);
		add(pt0, pt2);
		// compute the new sum of squares
		Object ptSqr0 = newCopy(ptSqr1);
		add(ptSqr0, ptSqr2);
		// compute the variance
		return variance(m0, pt0, ptSqr0);
	}
272013
public double variance(double m, Object pt, Object ptSqr) {
		Object x = newCopy(ptSqr);
//		// Var is E(X^2) - E(X)^2, but squaring pt1 introduces an extra factor which is the total mass, so:
		subtractScaledSqr(x, 1 / m, pt);
		return sum(x);
	}
1188869
def _expectation(p, mean1, none1, mean2, none2, nghp=None):
    
    return mean1(p.mu)[:, :, None] * mean2(p.mu)[:, None, :]
385222
def variance(self):
        """"""
        _self = self._discard_value(None)
        if not _self.total():
            return 0.0
        mean = _self.mean()
        weighted_central_moment = sum(
            count * (value - mean)**2 for value, count in iteritems(_self)
        )
        return weighted_central_moment / float(_self.total())
674735
function(mean, variance) {
    if (variance <= 0) {
      throw new Error('Variance must be > 0 (but was ' + variance + ')');
    }
    this.mean = mean;
    this.variance = variance;
    this.standardDeviation = Math.sqrt(variance);
  }
304911
def _psi2computations(dL_dpsi2, variance, Z, mu, S, gamma):
    
    # here are the "statistics" for psi1 and psi2
    # Produced intermediate results:
    # _psi2_dvariance      Q
    # _psi2_dZ             MxQ
    # _psi2_dgamma         NxQ
    # _psi2_dmu            NxQ
    # _psi2_dS             NxQ
    
    mu2 = np.square(mu)
    gamma2 = np.square(gamma)
    variance2 = np.square(variance)
    mu2S = mu2+S # NxQ
    gvm = gamma*mu*variance
    common_sum = gvm.dot(Z.T)
    Z_expect = (np.dot(dL_dpsi2,Z)*Z).sum(axis=0)
    Z_expect_var2 = Z_expect*variance2
    dL_dpsi2T = dL_dpsi2+dL_dpsi2.T
    common_expect = common_sum.dot(dL_dpsi2T).dot(Z)
    Z2_expect = common_sum.dot(dL_dpsi2T)
    Z1_expect = dL_dpsi2T.dot(Z)
    
    dL_dvar = variance*Z_expect*2.*(gamma*mu2S-gamma2*mu2).sum(axis=0)+(common_expect*gamma*mu).sum(axis=0)
        
    dL_dgamma = Z_expect_var2*(mu2S-2.*gamma*mu2)+common_expect*mu*variance
                
    dL_dmu = Z_expect_var2*mu*2.*(gamma-gamma2) + common_expect*gamma*variance

    dL_dS = gamma*Z_expect_var2
    
    dL_dZ = (gamma*(mu2S-gamma*mu2)).sum(axis=0)*variance2*Z1_expect+ Z2_expect.T.dot(gamma*mu)*variance

    return dL_dvar, dL_dgamma, dL_dmu, dL_dS, dL_dZ
726878
public static double variance(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh) {
        double variance = 0.0;
        
        int populationN = 0;
        
        double mean = mean(sampleDataCollection, populationNh);
        
        for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) {
            Object strata = entry.getKey();
            Integer strataPopulation = ((Number)populationNh.get(strata)).intValue();
        
            if(strataPopulation==null) {
                throw new IllegalArgumentException("Invalid strata population size.");
            }
            
            populationN+=strataPopulation;
            
            //Analysis of Variance
            
            //Within Strata
            variance+=(strataPopulation-1)*SimpleRandomSampling.variance(entry.getValue());
            //Between Strata
            variance+=strataPopulation*Math.pow(SimpleRandomSampling.mean(entry.getValue())-mean,2);
        }
        
        variance/=(populationN-1);

        return variance;
    }
562476
public static void standardize(double[] x) {
        double mu = mean(x);
        double sigma = sd(x);

        if (isZero(sigma)) {
            logger.warn("array has variance of 0.");
            return;
        }

        for (int i = 0; i < x.length; i++) {
            x[i] = (x[i] - mu) / sigma;
        }
    }
586805
public static double calPairwiseVariance(long count1, double sum1,
            double variance1, long count2, double sum2, double variance2) {
        return (variance1 * (count1 - 1) + variance2 * (count2 - 1)
                + pow(sum2 / count2 - sum1 / count1, 2) * count1 * count2
                / (count1 + count2))
                / (count1 + count2 - 1);
    }
413608
def variance
            expected = self.expectation
            @map.reduce(0) {|sum, (value,p)| 
                tmp = (value.to_f - expectation)
                sum + tmp * tmp * p 
            }
        end
939853
def variance(arg, where=None, how='sample'):
    
    expr = ops.Variance(arg, how, where).to_expr()
    expr = expr.name('var')
    return expr
525547
def weighted_std(values, weights):
    
    average = np.average(values, weights=weights)
    variance = np.average((values-average)**2, weights=weights)
    return np.sqrt(variance)
545425
public static double variance( GrayS16 img , double mean ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.variance(img,mean);
		} else {
			return ImplImageStatistics.variance(img,mean);
		}
	}