Skip to content

Main content

Root Mean Square Calculator Source Code

Browse the implementation files for Root Mean Square Calculator.
tool.ts typescript
import { runRootMeanSquare } from '@tool.io/tools/statistics/root-mean-square';
import { parseFiniteNumberList } from '../../parse/numeric-dataset/tool';

export const rootMeanSquare = (input: unknown): string => {
	const values = parseFiniteNumberList(input);
	if (!values) return '';
	const result = runRootMeanSquare({ values });
	return result.ok ? String(result.output.rootMeanSquare) : '';
};

export const Tool: TypeTool = {
	name: 'Root Mean Square Calculator',
	slug: 'statistics/root-mean-square',
	intro:
		'Calculate the quadratic mean, or root mean square, of a list of numbers.',
	tool: rootMeanSquare,
	i: [
		{
			example: '1, 2, 3',
			label: 'Numbers',
			placeholder: 'Comma-, space-, or line-separated numbers',
			render: 'textarea',
			type: 'text'
		}
	],
	o: [
		{
			example: '2.160246899469287',
			label: 'Root Mean Square',
			placeholder: 'RMS will appear here...',
			type: 'number'
		}
	],
	equation:
		'$$x_{RMS}=\\sqrt{\\frac{1}{n}\\sum_{i=1}^{n}x_i^2}$$'
};
export default Tool;

Description

Browse the implementation files for Root Mean Square Calculator.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools