input for average

@function avg
@param {String} line - line read
@param {Array} output - object stored
@return {Object}
774196
function avg(line, params) {

  var event = params[0];
  var what = params[1];
  var r = Number(line[what]);
  event.what += r;
  ++event.total;
  if (r > event.max) {
    event.max = r;
  }
  if (r < event.min) {
    event.min = r;
  }
  return event;
}
1087813
function parseOutput(output) {
  if (!output) {
    throw new Error('Expected JSON output');
  }

  let info;
  try {
    info = JSON.parse(String(output));
  } catch (err) {
    throw new Error('Failed to parse output as JSON: ' + output);
  }
  if (!Array.isArray(info.symbols)) {
    throw new Error('Expected symbols array: ' + output);
  }
  if (!Array.isArray(info.defines)) {
    throw new Error('Expected defines array: ' + output);
  }

  return info;
}
524576
def average():
    
    count = 0
    total = total()
    i=0
    while 1:
        i = yield ((total.send(i)*1.0)/count if count else 0)
        count += 1
53519
function mean(input) {
                if (!Array.isArray(input)) {
                    throw new Error('input must be an array');
                }

                if (input.length === 0) {
                    throw new Error('input must not be empty');
                }

                var sum = 0;
                for (var i = 0; i < input.length; i++) {
                    sum += input[i];
                }
                return sum / input.length;
            }
1091678
function line_number(index, source) {
  // To speed things up, remember the index until which we counted,
  // then next time just begin counting from there.  This way we
  // only count each line once.
  var i = start_index;
  var count = 0;
  while (i < index) {
    if (source[i] === "\n") {
      count++;
    }
    i++;
  }

  start_linenr = count + start_linenr;
  start_index = index;

  return start_linenr;
}
937815
public static <T extends ImageGray<T>> void stdDev(Planar<T> input, T output, @Nullable T avg) {
		stdDev(input, output, avg, 0, input.getNumBands() - 1);
	}
826398
def avg(vals, count=None):
     
    sum = 0
    for v in vals:
        sum += v
    if count is None:
        count = len(vals)
    return float(sum) / count
1301530
protected static double[] average(double[] base, double[] target)
    {
        int dataNum = base.length;
        double[] average = new double[dataNum];

        for (int index = 0; index < dataNum; index++)
        {
            average[index] = (base[index] + target[index]) / 2.0;
        }

        return average;
    }
465995
def parse_output(self, line):
        """"""

        try:
            key, value = line.split(":")
            self.update_value(key.strip(), value.strip())
        except ValueError:
            pass
227505
public static int readLine(InputStream in,
                               OutputStream out) throws IOException {

        int count = 0;

        for (;;) {
            int b = in.read();

            if (b == -1) {
                break;
            }

            count++;

            out.write(b);

            if (b == '\n') {
                break;
            }
        }

        return count;
    }
65289
def variance(arr):
  
  avg = average(arr)
  return sum([(float(x)-avg)**2 for x in arr])/float(len(arr)-1)
1048914
def stats():
    ''''''
    import re
    import sys
    import math
    values = []
    for line in sys.stdin:
        values.extend(map(float, re.findall(r'\d+\.?\d+', line)))

    mean = sum(values) / len(values)
    variance = sum((val - mean) ** 2 for val in values) / len(values)
    print '%3i items; mean: %10.5f; std-dev: %10.5f' % (
        len(values), mean, math.sqrt(variance))
68637
function median( out, x ) {
	var len = x.length,
		i;
	if ( out.length !== len ) {
		throw new Error( 'median()::invalid input arguments. Input and output matrices must be the same length.' );
	}
	for ( i = 0; i < len; i++ ) {
		out.data[ i ] = MEDIAN( x.data[ i ] );
	}
	return out;
}
860634
private double computeOutputError(double[] output, double[] gradient) {
        if (output.length != outputLayer.units) {
            throw new IllegalArgumentException(String.format("Invalid output vector size: %d, expected: %d", output.length, outputLayer.units));
        }

        double error = 0.0;
        for (int i = 0; i < outputLayer.units; i++) {
            double out = outputLayer.output[i];
            double g = output[i] - out;

            if (errorFunction == ErrorFunction.LEAST_MEAN_SQUARES) {
                error += 0.5 * g * g;
            } else if (errorFunction == ErrorFunction.CROSS_ENTROPY) {
                if (activationFunction == ActivationFunction.SOFTMAX) {
                    error -= output[i] * log(out);
                } else if (activationFunction == ActivationFunction.LOGISTIC_SIGMOID) {
                    // We have only one output neuron in this case.
                    error = -output[i] * log(out) - (1.0 - output[i]) * log(1.0 - out);
                }
            }

            if (errorFunction == ErrorFunction.LEAST_MEAN_SQUARES && activationFunction == ActivationFunction.LOGISTIC_SIGMOID) {
                g *= out * (1.0 - out);
            }

            gradient[i] = g;
        }

        return error;
    }
283195
function avg (arr) {
    if (isArray(arr) && !(arr[0] instanceof Array)) {
        const totalSum = sum(arr);
        const len = arr.length || 1;
        return (Number.isNaN(totalSum) || totalSum instanceof InvalidAwareTypes) ?
                 InvalidAwareTypes.NULL : totalSum / len;
    }
    return InvalidAwareTypes.NULL;
}
1045106
def _extract_stats_from_line(self, txt, stats_delim=' ', val_delim=':'):
        
        result = {}
        stats_txt = txt.split(stats_delim)
        for s in stats_txt:
            #print('s = ', s)
            if s.strip(' ').strip('\n') != '':
                k,v = s.split(val_delim)
                result[k.strip(' ')] = v.strip(' ').strip('\n')
        return result
119440
function lineCount(value) {
        var rows = 0;
        if (value) {
            rows = 1;
            value.toString().each(/\n/, function () { return rows++; });
        }
        return rows;
    }