Calculate the statistics
495146
public void calculate() throws IOException {
        OggStreamAudioData data;

        // Calculate the headers sizing
        OggAudioInfoHeader info = headers.getInfo();
        handleHeader(info);
        handleHeader(headers.getTags());
        handleHeader(headers.getSetup());

        // Have each audio packet handled, tracking at least granules
        while ((data = audio.getNextAudioPacket()) != null) {
            handleAudioData(data);
        }

        // Calculate the duration from the granules, if found
        if (lastGranule > 0) {
            long samples = lastGranule - info.getPreSkip();
            double sampleRate = info.getSampleRate();
            if (info instanceof OpusInfo) {
                // Opus is a special case - granule *always* runs at 48kHz
                sampleRate = OpusAudioData.OPUS_GRANULE_RATE;
            }
            durationSeconds = samples / sampleRate;
        }
    }
1031322
def stats(name, array, *extras):
    
    std = numpy.nan if len(array) == 1 else numpy.std(array, ddof=1)
    return (name, numpy.mean(array), std,
            numpy.min(array), numpy.max(array), len(array)) + extras
1020435
def statistics(self):
        
        if self._statistics is None:
            self._statistics = WorkspaceStatisticsList(self._version, workspace_sid=self._solution['sid'], )
        return self._statistics
1224840
def count(self, stats, value, sample_rate=1):
        
        self.update_stats(stats, value, self.SC_COUNT, sample_rate)
153749
def describe(self):
        
        stats = {}
        stats['samples'] = self.shape[0]
        stats['nulls'] = self[np.isnan(self)].shape[0]
        stats['mean'] = float(np.nanmean(self.real))
        stats['min'] = float(np.nanmin(self.real))
        stats['max'] = float(np.nanmax(self.real))
        return stats
483392
function onStats( error, stat ) {
		if ( error ) {
			return clbk( error );
		}
		m.mem.memUsed = stat.memory / 1000; // KB
		m.mem.utilization = stat.memory / os.totalmem();
		m.cpu = {
			'utilization': stat.cpu / 100
		};
		clbk( null, m );
	}
879252
def print_statistics(self):
        
        print("Q1 =", self.Q1)
        print("Q2 =", self.Q2)
        print("cR =", self.cR)
1275601
def stats(self):
        
        return OrderedDict([
            ("Intervals", len(self.array)),
            ("Mean", self.format_time(self.mean or 0)),
            ("Min", self.format_time(self.min or 0)),
            ("Median", self.format_time(self.median or 0)),
            ("Max", self.format_time(self.max or 0)),
            ("St. Dev.", self.format_time(self.stdev or 0)),
            ("Total", self.format_time(self.exectime or 0)),
        ])
1279900
protected void init_stats() {
		byteCount = 0;
		ctrlWordCount = 0;
		openGroupCount = 0;
		closeGroupCount = 0;
		characterCount = 0;
		ctrlWordHandledCount = 0;
		ctrlWordNotHandledCount = 0;
		ctrlWordSkippedCount = 0;
		groupSkippedCount = 0;
	}
849995
function() {
			// Get the mean
			var mean = this.mean();

			// Get a new stats object to work with
			var nums = this.clone();

			// Map each element of nums to the square of the element minus the
			// mean
			nums.map(function(num) {
				return Math.pow(num - mean, 2);
			});

			// Return the standard deviation
			return Math.sqrt(nums.sum() / (nums.size() - 1));
		}
475309
def stats(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.stats(index=self._name, **kwargs)
37268
def finish_statistics(self):
        
        # params = self.stat.setup_params(self.data)
        self.stat.finish_layer(self.data, self.stat.params)
823247
def sum_stats(stats_data):
    
    t_bounces = 0
    t_complaints = 0
    t_delivery_attempts = 0
    t_rejects = 0
    for dp in stats_data:
        t_bounces += int(dp['Bounces'])
        t_complaints += int(dp['Complaints'])
        t_delivery_attempts += int(dp['DeliveryAttempts'])
        t_rejects += int(dp['Rejects'])

    return {
        'Bounces': t_bounces,
        'Complaints': t_complaints,
        'DeliveryAttempts': t_delivery_attempts,
        'Rejects': t_rejects,
    }
575790
def variance(self) -> Optional[float]:  #, ddof: int = 0) -> float:
        
        # TODO: Add DOF
        # http://stats.stackexchange.com/questions/6534/how-do-i-calculate-a-weighted-standard-deviation-in-excel
        if self._stats:
            if self.total > 0:
                return (self._stats["sum2"] - self._stats["sum"] ** 2 / self.total) / self.total
            else:
                return np.nan
        else:
            return None
852039
def calculate_columns(self):
        """"""

        self.cols = int(math.ceil(len(self.elements) / float(self.rows)))
1214683
def Mean(self):
        
        mu = 0.0
        for x, p in self.d.iteritems():
            mu += p * x
        return mu
485740
function(dataset) {

		// calculate counts for equation (3):
		var mapWordToTotalCount = {};
		var totalNumberOfWordsInDataset = 0;
		for (var i in dataset) {
			var datum = dataset[i];
			var totalPerDatum = 0;
			
			// for each input sentence, count the total number of words in it:
			for (var word in datum) {
				mapWordToTotalCount[word] |= 0;
				mapWordToTotalCount[word] += datum[word];
				totalPerDatum += datum[word];
			}
			datum["_total"] = totalPerDatum;
			totalNumberOfWordsInDataset += totalPerDatum;
		}
		mapWordToTotalCount["_total"] = totalNumberOfWordsInDataset;
		
		this.dataset = dataset;
		this.mapWordToTotalCount = mapWordToTotalCount;
		
		// calculate smoothing factor for equation (3):
		var mapWordToSmoothingFactor = {};
		for (var word in mapWordToTotalCount) {
			mapWordToSmoothingFactor[word] = 
				(1-this.smoothingCoefficient) * this.mapWordToTotalCount[word] / this.mapWordToTotalCount["_total"];
		}
		this.mapWordToSmoothingFactor = mapWordToSmoothingFactor;
		
		this.globalSmoothingFactor = (1/totalNumberOfWordsInDataset)  // a global smoother, for totally unseen words.
	}