Bookmark this: tool.io/statistics/two-sample-t-test/source-code
Two-Sample T-Test Calculator Source Code
Browse the implementation files for Two-Sample T-Test Calculator.tool.ts typescript
import { calculateTwoSampleTTest as calculatePortableTwoSampleTTest } from '@tool.io/tools/statistics/two-sample-t-test';
export const calculateTwoSampleTTest = (
first: unknown,
second: unknown,
method: unknown = 'welch'
): string => {
const result = calculatePortableTwoSampleTTest({
equalVariance: method === 'pooled',
first,
second
});
return result.ok
? JSON.stringify(result.output, null, 2)
: '';
};
export const Tool: TypeTool = {
name: 'Two-Sample T-Test Calculator',
slug: 'statistics/two-sample-t-test',
intro:
"Calculate Welch's or pooled two-sample t statistic for independent samples.",
tool: calculateTwoSampleTTest,
i: [
{
example: '12, 14, 15, 13, 16',
label: 'First Sample',
placeholder: 'Numeric values',
render: 'textarea',
type: 'text'
},
{
example: '10, 11, 13, 12, 14',
label: 'Second Sample',
placeholder: 'Numeric values',
render: 'textarea',
type: 'text'
},
{
label: 'Variance Method',
options: [
{
selected: true,
text: 'Welch (unequal variance)',
value: 'welch'
},
{ text: 'Pooled (equal variance)', value: 'pooled' }
],
placeholder: 'Select a method',
type: 'select',
value: 'welch'
}
],
o: [
{
example: '{ "tStatistic": 1.2 }',
label: 'T-Test Result',
placeholder: 'Result will appear here...',
render: 'textarea',
type: 'text'
}
]
};
export default Tool;
Description
Browse the implementation files for Two-Sample T-Test Calculator.