# How to use the simple-statistics.min 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.

kartotherian / kartotherian / test / tile-profiler.js View on Github
``````source._backend.getTile(0,0,0, function(err, vtile, headers) {
if (err) throw err;
var tile = vtile;
var layerInfo = profiler.layerInfo(tile);

// Tile has a 'coastline' layer
var coastline = _(layerInfo).where({ name: 'coastline' })[0];
t.ok(coastline);

// Tile contains 4177 features
t.equal(coastline.coordCount.length, 1437);
t.equal(coastline.features, 1437);

// Longest/shortest features
t.equal(ss.max(coastline.coordCount), 380);
t.equal(ss.min(coastline.coordCount), 2);

// Most/least duplication
t.equal(ss.max(coastline.duplicateCoordCount), 0);
t.equal(ss.min(coastline.duplicateCoordCount), 0);

// Max/Min distance between consecutive coords
var diff = Math.abs(ss.max(coastline.coordDistance) - 570446.5598775251);
t.ok(diff &lt; 0.1);
t.equal(ss.min(coastline.coordDistance), 1181.6043940629547);

// Expected jsonsize
t.equal(coastline.jsonsize, 520120);

t.end();
});
});``````
jeromeetienne / poker-hand.js / scripts / montecarlo-accuracy-comparison.js View on Github
``````[100, 500, 1000, 2000, 3000, 5000, 10000].forEach(function(nRounds){
let nSimulations = 20
let results = []
for(let i = 0; i &lt; nSimulations; i++){
// console.log(`do simulation \${i} with \${nRounds} rounds`)
var result = PokerHand.MonteCarlo.simulateOddsIfAllIn(nRounds, holeCards, communityCards, nbOtherPlayers)
results.push(result)
}

// compute stats on the results
let mean = SimpleStats.mean(results)
let stddev = SimpleStats.standardDeviation(results)
let max = SimpleStats.max(results)
let min = SimpleStats.min(results)
console.log(`nRounds \${nRounds.toString().padStart(5)} : mean \${mean.toFixed(6)} (\${Math.round(mean*100).toString().padStart(2)}%) - stddev \${stddev.toFixed(6)} - delta min/max [\${(min-mean).toFixed(6)}, \${(max-mean).toFixed(6)}]`)
})``````
IBM / openapi-to-graphql / test / evaluation / eval_apis_guru.js View on Github
``````function printSummary (arr) {
console.log(`mean: \${ss.mean(arr)}`)
console.log(`min:  \${ss.min(arr)}`)
console.log(`max:  \${ss.max(arr)}`)
console.log(`---`)
console.log(`25%:  \${ss.quantile(arr, 0.25)}`)
console.log(`50%:  \${ss.quantile(arr, 0.50)}`)
console.log(`75%:  \${ss.quantile(arr, 0.75)}`)
console.log(`90%:  \${ss.quantile(arr, 0.9)}`)
}``````
antvis / data-set / test / unit / api / statistics-spec.ts View on Github
``````},
});
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)]);
});``````
RequestNetwork / requestNetwork / packages / prototype-estimator / src / calculateLatency.ts View on Github
``````}
if (getTransactionsByChannelIdCount > 0) {
console.log(`\ngetTransactionsByChannelId statistics`);
console.log(`average: \${simpleStatistics.mean(getTransactionsByChannelIdTimes)}`);
console.log(`median: \${simpleStatistics.median(getTransactionsByChannelIdTimes)}`);
console.log(`min: \${simpleStatistics.min(getTransactionsByChannelIdTimes)}`);
console.log(`max: \${simpleStatistics.max(getTransactionsByChannelIdTimes)}`);
console.log(
`standard deviation: \${simpleStatistics.standardDeviation(getTransactionsByChannelIdTimes)}`,
);
}
if (persistTransactionCount > 0) {
console.log(`\npersistTransaction statistics`);
console.log(`average: \${simpleStatistics.mean(persistTransactionTimes)}`);
console.log(`median: \${simpleStatistics.median(persistTransactionTimes)}`);
console.log(`min: \${simpleStatistics.min(persistTransactionTimes)}`);
console.log(`max: \${simpleStatistics.max(persistTransactionTimes)}`);
console.log(
`standard deviation: \${simpleStatistics.standardDeviation(persistTransactionTimes)}`,
);
}
});``````
RequestNetwork / requestNetwork / packages / prototype-estimator / src / calculateLatency.ts View on Github
``````readlineInterface.on('close', () => {
console.log(
`\${getChannelsByTopicCount +
getTransactionsByChannelIdCount +
persistTransactionCount} requests`,
);
console.log(`\${getChannelsByTopicCount} getChannelsByTopic requests`);
console.log(`\${getTransactionsByChannelIdCount} getTransactionsByChannelId requests`);
console.log(`\${persistTransactionCount} persistTransaction requests`);

if (getChannelsByTopicCount > 0) {
console.log(`\ngetChannelsByTopic statistics`);
console.log(`average: \${simpleStatistics.mean(getChannelsByTopicTimes)}`);
console.log(`median: \${simpleStatistics.median(getChannelsByTopicTimes)}`);
console.log(`min: \${simpleStatistics.min(getChannelsByTopicTimes)}`);
console.log(`max: \${simpleStatistics.max(getChannelsByTopicTimes)}`);
console.log(
`standard deviation: \${simpleStatistics.standardDeviation(getChannelsByTopicTimes)}`,
);
}
if (getTransactionsByChannelIdCount > 0) {
console.log(`\ngetTransactionsByChannelId statistics`);
console.log(`average: \${simpleStatistics.mean(getTransactionsByChannelIdTimes)}`);
console.log(`median: \${simpleStatistics.median(getTransactionsByChannelIdTimes)}`);
console.log(`min: \${simpleStatistics.min(getTransactionsByChannelIdTimes)}`);
console.log(`max: \${simpleStatistics.max(getTransactionsByChannelIdTimes)}`);
console.log(
`standard deviation: \${simpleStatistics.standardDeviation(getTransactionsByChannelIdTimes)}`,
);
}
if (persistTransactionCount > 0) {``````
morganherlocker / geocolor / lib / geocolor.js View on Github
``````equalIntervals: function(fc, z, numBreaks, colors, style){
var vals = _.chain(fc.features)
.pluck('properties')
.pluck(z)
.value()

var min = ss.min(vals)
var max = ss.max(vals)
var interval = (max - min) / numBreaks
var breaks = [0]
var currentBreak = 0
for(var i=0;i&lt;=numBreaks;i++){
currentBreak += interval
breaks.push(currentBreak)
}
var normals = normalize(breaks.length)
fc = colorize(fc, z, colors, breaks, normals)
fc = setLegend(fc, z, colors, breaks, normals)
fc = applyStyle(fc, style)
return fc
},``````
poanetwork / token-bridge / scripts / compute-stats.js View on Github
``````function computeCollectedSignaturesStats(collectedSignatures, senderForeign) {
const processingLogs = collectedSignatures.filter(x => x.eventTransactionHash)
const txSentMap = senderForeign
.filter(x => x.eventTransactionHash)
.reduce((acc, x) => {
acc[x.eventTransactionHash] = x
return acc
}, {})

const times = processingLogs.map(x => txSentMap[x.eventTransactionHash].time - x.time)

return {
count: times.length,
mean: mean(times),
median: median(times),
min: min(times),
max: max(times)
}
}``````
poanetwork / token-bridge / scripts / compute-stats.js View on Github
``````function computeSignatureRequestStats(signatureRequests, senderHome) {
const processingLogs = signatureRequests.filter(x => x.eventTransactionHash)
const txSentMap = senderHome
.filter(x => x.eventTransactionHash)
.reduce((acc, x) => {
acc[x.eventTransactionHash] = x
return acc
}, {})

const times = processingLogs.map(x => txSentMap[x.eventTransactionHash].time - x.time)

return {
count: times.length,
mean: mean(times),
median: median(times),
min: min(times),
max: max(times)
}
}``````

## simple-statistics

Simple Statistics

ISC