Bookmark this: tool.io/statistics/arithmetic-mean/source-code
Arithmetic Mean Calculator Source Code
Browse the implementation files for Arithmetic Mean Calculator.tool.ts typescript
import { runMean } from '@tool.io/tools/statistics/mean';
import { parseFiniteNumberList } from '../../parse/numeric-dataset/tool';
export const arithmeticMean = (input: unknown): string => {
const values = parseFiniteNumberList(input);
if (!values) return '';
const result = runMean({ values });
return result.ok ? String(result.output.mean) : '';
};
export const Tool: TypeTool = {
name: 'Arithmetic Mean Calculator',
slug: 'statistics/arithmetic-mean',
intro:
'Calculate the arithmetic average of a list of numbers.',
tool: arithmeticMean,
i: [
{
example: '2, 4, 6, 8',
label: 'Numbers',
placeholder: 'Comma-, space-, or line-separated numbers',
render: 'textarea',
type: 'text'
}
],
o: [
{
example: '5',
label: 'Arithmetic Mean',
placeholder: 'Mean will appear here...',
render: 'textarea',
type: 'text'
}
],
equation: '$$\\bar{x}=\\frac{1}{n}\\sum_{i=1}^{n}x_i$$',
alternative: [{ title: 'Mean', url: '/statistics/mean' }]
};
export default Tool;
Description
Browse the implementation files for Arithmetic Mean Calculator.