# How to use the simple-statistics.variance function in simple-statistics

## To help you get started, weâ€™ve selected a few simple-statistics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

antvis / data-set / test / unit / api / statistics-spec.ts View on Github
``````return row;
},
});
const years = dv.getColumn('year');
expect(dv.max('year')).to.equal(max(years));
expect(dv.min('year')).to.equal(min(years));
expect(dv.mean('year')).to.equal(mean(years));
expect(dv.average('year')).to.equal(mean(years));
expect(dv.median('year')).to.equal(median(years));
expect(dv.mode('year')).to.equal(mode(years));
expect(dv.quantile('year', 0.5)).to.equal(quantile(years, 0.5));
expect(dv.quantiles('year', [0, 0.1, 0.5])).to.eql(map([0, 0.1, 0.5], (p) => quantile(years, p)));
expect(dv.quantilesByFraction('year', 4)).to.eql(map([0, 0.25, 0.5, 0.75, 1], (p) => quantile(years, p)));
expect(dv.standardDeviation('year')).to.equal(standardDeviation(years));
expect(dv.sum('year')).to.equal(sum(years));
expect(dv.variance('year')).to.equal(variance(years));
expect(dv.range('year')).to.eql([min(years), max(years)]);
});``````
antvis / data-set / test / unit / api / statistics-spec.ts View on Github
``````});
}
const dv = new DataSet.View().source(data);
const values = flattenDeep(dv.getColumn('a'));
expect(dv.max('a')).to.equal(max(values));
expect(dv.min('a')).to.equal(min(values));
expect(dv.mean('a')).to.equal(mean(values));
expect(dv.average('a')).to.equal(mean(values));
expect(dv.median('a')).to.equal(median(values));
expect(dv.mode('a')).to.equal(mode(values));
expect(dv.quantile('a', 0.5)).to.equal(quantile(values, 0.5));
expect(dv.quantiles('a', [0, 0.1, 0.5])).to.eql(map([0, 0.1, 0.5], (p) => quantile(values, p)));
expect(dv.quantilesByFraction('a', 4)).to.eql(map([0, 0.25, 0.5, 0.75, 1], (p) => quantile(values, p)));
expect(dv.standardDeviation('a')).to.equal(standardDeviation(values));
expect(dv.sum('a')).to.equal(sum(values));
expect(dv.variance('a')).to.equal(variance(values));
expect(dv.range('a')).to.eql([min(values), max(values)]);
});
});``````
bitrinjani / r2 / plugins / SimpleSpreadStatHandler.js View on Github
``````constructor(history) {
this.log = getLogger(this.constructor.name);
const profitPercentHistory = history.map(x => x.bestCase.profitPercentAgainstNotional);
this.sampleSize = profitPercentHistory.length;
this.profitPercentMean = this.sampleSize != 0 ? ss.mean(profitPercentHistory) : 0;
this.profitPercentVariance = this.sampleSize != 0 ? ss.variance(profitPercentHistory) : 0;
}``````
Turfjs / turf / packages / turf-variance / index.js View on Github
``````polyFC.features.forEach(function (poly) {
if (!poly.properties) {
poly.properties = {};
}
var values = [];
ptFC.features.forEach(function (pt) {
if (inside(pt, poly)) {
values.push(pt.properties[inField]);
}
});
poly.properties[outField] = ss.variance(values);
});``````
Turfjs / turf / lib / variance.js View on Github
``````_.each(polyFC.features, function(poly){
if(!poly.properties){
poly.properties = {}
}
var values = []
_.each(ptFC.features, function(pt){
t.inside(pt, poly, function(err, isInside){
if(isInside){
values.push(pt.properties[inField])
}
})
})
poly.properties[outField] = ss.variance(values)
})
done(null, polyFC)``````

## simple-statistics

Simple Statistics

ISC
Latest version published 1 year ago

67 / 100