Takes a list of rows and a column and returns the mean of the values under that column in
        those rows.
352983
def average(self, rows: List[Row], column: NumberColumn) -> Number:
        
        cell_values = [row.values[column.name] for row in rows]
        if not cell_values:
            return 0.0  # type: ignore
        return sum(cell_values) / len(cell_values)
16309
def partition(list_, columns=2):
    

    iter_ = iter(list_)
    columns = int(columns)
    rows = []

    while True:
        row = []
        for column_number in range(1, columns + 1):
            try:
                value = six.next(iter_)
            except StopIteration:
                pass
            else:
                row.append(value)

        if not row:
            return rows
        rows.append(row)
688269
def sparse(self, rows: np.ndarray, cols: np.ndarray) -> scipy.sparse.coo_matrix:
		
		return scipy.sparse.coo_matrix(self.values[rows, :][:, cols])
393032
def samplevar(inlist):
    
    n = len(inlist)
    mn = mean(inlist)
    deviations = []
    for item in inlist:
        deviations.append(item - mn)
    return ss(deviations) / float(n)
396285
def mkcols(l, rows):
    '''
    
    '''
    cols = []
    base = 0
    while len(l) > rows and len(l) % rows != 0:
        l.append("")
    for i in range(rows, len(l) + rows, rows):
        cols.append(l[base:i])
        base = i
    return cols
530842
def moving_average(self, data, days):
        
        result = []
        data = data[:]
        for dummy in range(len(data) - int(days) + 1):
            result.append(round(sum(data[-days:]) / days, 2))
            data.pop()
        result.reverse()
        return result
1217173
def mean(values)
      raise "values must be an array" unless values.is_a?(Array)

      values.inject(0) {|sum, x| sum + x}.to_f / values.length
    end
275043
def _compute_mean(self, C, A1, A2, A3, A4, A5, A6, mag, hypo_depth,
                      rrup, mean, idx):
        
        mean[idx] = (A1 + A2 * mag + C['C1'] + C['C2'] * (A3 - mag) ** 3 +
                     C['C3'] * np.log(rrup[idx] + A4 * np.exp(A5 * mag)) +
                     A6 * hypo_depth)
727401
function Bias(average, rowBiases, colBiases) {
	this.average = average;		// Overall value average
	this.rowBiases = rowBiases; // Bias for each row
	this.colBiases = colBiases;	// Bias for each column
}
89265
private static double[][] rowsum(double[][] rr, ArrayList<String> sets) throws Exception {
		LinkedHashMap<String, Double> sumMap = new LinkedHashMap<String, Double>();
		if (rr.length != sets.size()) {
			throw new Exception("Cluster value for each sample are not of equal length n=" + rr.length + " cluster length=" + sets.size());
		}
		double[][] sum = null;
		for (int j = 0; j < rr[0].length; j++) {
			for (int i = 0; i < sets.size(); i++) {
				String s = sets.get(i);
				Double v = sumMap.get(s); //get in order
				if (v == null) {
					v = 0.0;
				}
				v = v + rr[i][j];
				sumMap.put(s, v);

			}
			if (sum == null) {
				sum = new double[sumMap.size()][rr[0].length];
			}

			ArrayList<String> index = new ArrayList<String>(sumMap.keySet());
			//sorting does seem to make a difference in test cases at the .0000000001
	   //     ArrayList<Integer> in = new ArrayList<Integer>();
	   //     for (String s : index) {
	   //         in.add(Integer.parseInt(s));
	   //     }
	   //     Collections.sort(index);

			for (int m = 0; m < index.size(); m++) {
				String key = index.get(m);
				sum[m][j] = sumMap.get(key);
			}

			sumMap.clear();
		}

		return sum;

	}
1214683
def Mean(self):
        
        mu = 0.0
        for x, p in self.d.iteritems():
            mu += p * x
        return mu
550777
function _getRows(matrix) {
  var rows = [];
  for (var i=0; i<matrix.size.rows; i++) {
    rows.push([]);
    for (var j=0; j<matrix.size.columns; j++)
      rows[i].push(matrix.values[matrix.size.columns * i + j]);
  }
  return rows;
}
530790
def _get_normalized_columns(cls, list_):
        
        ret = []
        for row in list_:
            if len(row.keys()) > len(ret):
                ret = cls._ordered_keys(row)

        for row in list_:
            for key in row.keys():
                if key not in ret:
                    ret.append(key)
                    if not isinstance(row, OrderedDict):
                        ret.sort()
        return ret
546326
def stats(self, columns):
        
        assert (not isinstance(columns, basestring)), "columns should be a " \
                                                      "list of strs,  " \
                                                      "not a str!"
        assert isinstance(columns, list), "columns should be a list!"

        from pyspark.sql import functions as F
        functions = [F.min, F.max, F.avg, F.count]
        aggs = list(
            self._flatmap(lambda column: map(lambda f: f(column), functions),
                          columns))
        return PStats(self.from_schema_rdd(self._schema_rdd.agg(*aggs)))
808907
def meanMutualInformation(sp, activeColumnsCurrentEpoch, columnsUnderInvestigation = []):
  
  if len(columnsUnderInvestigation) == 0:
    columns = range(np.prod(sp.getColumnDimensions()))
  else:
    columns = columnsUnderInvestigation
  numCols = len(columns)
  sumMutualInfo = 0
  normalizingConst = numCols*(numCols - 1)/2
  for i in range(numCols):
    for j in range(i+1, numCols):
      sumMutualInfo += mutualInformation(sp, activeColumnsCurrentEpoch, columns[i], columns[j])

  return sumMutualInfo/normalizingConst
1056318
public static double varianceDoublematrixColumn( double[][] matrix, int column, double mean )

    {

        double variance;

        variance = 0;

        for( int i = 0; i < matrix.length; i++ ) {
            variance += (matrix[i][column] - mean) * (matrix[i][column] - mean);
        }

        return variance / matrix.length;

    }
474372
def df_weighted_average_grouped(dataframe, groupe, varlist):
    '''
    
    '''
    return DataFrame(
        dict([
            (var, collapse(dataframe, groupe, var)) for var in varlist
            ])
        )