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

codeformunich / radlquartier / datatool / preprocess / index-qhs.js View on Github
``````data.weeks.push(year.weeks[w]);
}

for (var wd = 0; wd &lt; 7; wd++) {
data.weekDays[wd] = data.weekDays[wd].concat(year.weekDays[wd]);
}

data.days = data.days.concat(year.days);
}

// districtData.data = data;

// calculate means
districtData.meanYears = ss.mean(data.years);
districtData.meanMonth = ss.mean(data.month);

for (var l = 0; l &lt; 12; l++) {
if (data.yearMonth[l].length === 0) {
districtData.meanYearMonth[l] = 0;
}
else if (data.yearMonth[l].length === 1) {
districtData.meanYearMonth[l] = data.yearMonth[l][0];
}
else {
districtData.meanYearMonth[l] = ss.mean(data.yearMonth[l]);
}

if (output.districts.length === 0) {
output.meanYearMonth[l] = districtData.meanYearMonth[l];
}
else {``````
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
``````it('statistics methods', () => {
const dv = new DataSet.View().source(populationChina);
dv.transform({
type: 'map',
callback(row) {
row.year = parseInt(row.year, 10);
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)]);
});``````
jbeuckm / strapi-plugin-import-content / services / utils / analyzer.js View on Github
``````.sortBy('count')
.reverse()
.get('type')
.value();
} catch (e) {
console.log(e);
}

fieldStat.hasImageUrls = fieldAnalysis.some(fa => Boolean(fa.hasImageUrls));

const lengths = _.map(fieldAnalysis, 'length');

fieldStat.minLength = ss.min(lengths);
fieldStat.maxLength = ss.max(lengths);
fieldStat.meanLength = ss.mean(lengths).toFixed(2);

return fieldStat;
});``````
CenterForOpenScience / osf.io / admin / static / js / sales_analytics / dashboard.js View on Github
``````self.keenClient.run([queryUser, queryMAU], function (error, response) {
var resultUser;
var resultMAU;
if (error) {
document.getElementById('keen-chart-average-session-history').innerHTML = 'failure ... : ' + (12 - numberOfWeeks) + ' / 12';
console.log(error);
resultUser = resultMAU = -1;
}
else {
var dataSetUser = self.extractDataSet(response[0]);
var dataSetMAU = self.extractDataSet(response[1]);
resultUser = ss.mean(dataSetUser);
resultMAU = ss.mean(dataSetMAU);
}
var item = {
timeframe: {
start: weekStart.toISOString(),
end: weekEnd.toISOString()
},
value: [
{ category: 'User', result: resultUser/1000/60 },
{ category: 'MAU', result: resultMAU/1000/60 }
]
};
weeklyResult.push(item);

weekEnd = new Date(weekStart);
weekStart.setDate(weekEnd.getDate() - 7);``````
makebrainwaves / BrainWaves / app / utils / behavior / compute.js View on Github
``````const y = subjects.map(subject =>
ss.mean(
transformedData
.filter(e => e.subject === subject)
.map(d => d.accuracy)
)
);``````
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)
}
}``````
gcgibson / NTM / copyTaskAbstractor.js View on Github
``````function averageShift(array){

return ss.mean(array);
}``````

## simple-statistics

Simple Statistics

ISC