import { Observation } from '../../types/types'; import { ParametersType, ToolInfo } from '../../types/tool_types'; import { BaseTool } from '../BaseTool'; const cohensDToolParams = [ { name: 'meandifference', type: 'number', description: 'The difference between the means of two groups', required: true }, { name: 'standarddeviation', type: 'number', description: 'The pooled standard deviation of the two groups', required: true }, { name: 'samplesize1', type: 'number', description: 'The sample size of the first group', required: true }, { name: 'samplesize2', type: 'number', description: 'The sample size of the second group', required: true } ] as const; type CohensDToolParamsType = typeof cohensDToolParams; const cohensDToolInfo: ToolInfo = { name: 'cohensdtool', description: 'Calculates Cohen\'s d for effect size and determines statistical significance levels.', citationRules: 'No citation needed.', parameterRules: cohensDToolParams }; export class CohensDTool extends BaseTool { constructor() { super(cohensDToolInfo); } async execute(args: ParametersType): Promise { const { meandifference, standarddeviation, samplesize1, samplesize2 } = args; const pooledSD = Math.sqrt(((samplesize1 - 1) * Math.pow(standarddeviation, 2) + (samplesize2 - 1) * Math.pow(standarddeviation, 2)) / (samplesize1 + samplesize2 - 2)); const cohensD = meandifference / pooledSD; return [{ type: 'text', text: `Cohen's d: ${cohensD.toFixed(3)}` }]; } }