Bookmark this: tool.io/statistics/interquartile-range/source-code
Interquartile Range Calculator Source Code
Browse the implementation files for Interquartile Range Calculator.tool.ts typescript
// Tool: Interquartile Range Calculator
//
// Calculates Q3-Q1 using the inclusive median-of-halves quartile method.
import { parseNumericDataset } from '../../parse/numeric-dataset/tool';
import { calculateInterquartileRange as calculatePortableInterquartileRange } from '@tool.io/tools/statistics/interquartile-range';
export const calculateInterquartileRange = (
values: readonly number[]
): number | null => calculatePortableInterquartileRange(values);
export const interquartileRange = (input: unknown): string => {
const values = parseNumericDataset(input);
if (values === null) return '';
const result = calculateInterquartileRange(values);
return result === null ? '' : String(result);
};
export const Tool: TypeTool = {
name: 'Interquartile Range Calculator',
slug: 'statistics/interquartile-range',
intro:
'Calculate the difference between Q3 and Q1 of a dataset.',
tool: interquartileRange,
i: [
{
example: '1, 2, 3, 4, 5, 6, 7, 8',
help: 'Enter finite numbers separated by commas or new lines.',
label: 'Numbers',
placeholder: 'Enter a dataset',
type: 'text',
render: 'textarea'
}
],
o: [
{
example: '4',
help: 'Q3 minus Q1 using the inclusive median-of-halves method.',
label: 'Interquartile Range',
placeholder: 'Interquartile range will appear here...',
type: 'number',
render: 'textarea'
}
],
equation: '$$\\operatorname{IQR}=Q_3-Q_1$$'
};
export default Tool;
Description
Browse the implementation files for Interquartile Range Calculator.