# Descriptive Statistics Calculator

• /
• Blog
• /
• Descriptive Statistics Calculator

# Descriptive Statistics Calculator

Enter numbers separated by commas:

Value
``` function calculateDescriptiveStatistics() { const input = document.getElementById('numbers-input').value; const output = document.getElementById('output').querySelector('tbody'); const numbers = input.split(',').map(num => parseFloat(num.trim())).filter(num => !isNaN(num)); if (numbers.length === 0) { alert('Please enter a valid comma-separated list of numbers.'); return; } // Calculations const count = numbers.length; const sum = numbers.reduce((sum, num) => sum + num, 0); const mean = sum / count; const sortedNumbers = numbers.slice().sort((a, b) => a - b); const median = count % 2 === 0 ? (sortedNumbers[count / 2 - 1] + sortedNumbers[count / 2]) / 2 : sortedNumbers[Math.floor(count / 2)]; const mode = [...numbers.reduce((countMap, num) => { countMap.set(num, (countMap.get(num) || 0) + 1); return countMap; }, new Map()).entries()].reduce((max, entry) => { return entry[1] > max[1] ? entry : max; }, [null, 0])[0]; const variance = numbers.reduce((sum, num) => sum + Math.pow(num - mean, 2), 0) / (count - 1); const variancePopulation = numbers.reduce((sum, num) => sum + Math.pow(num - mean, 2), 0) / count; const standardDeviation = Math.sqrt(variance); const standardDeviationPopulation = Math.sqrt(variancePopulation); const min = sortedNumbers[0]; const max = sortedNumbers[count - 1]; const range = max - min; const q1 = sortedNumbers[Math.floor(count * 0.25)]; const q3 = sortedNumbers[Math.floor(count * 0.75)]; const iqr = q3 - q1; const skewness = numbers.reduce((sum, num) => sum + Math.pow(num - mean, 3), 0) / count / Math.pow(standardDeviationPopulation, 3); const kurtosis = numbers.reduce((sum, num) => sum + Math.pow(num - mean, 4), 0) / count / Math.pow(standardDeviationPopulation, 4) - 3; const rows = [ ['Count', count], ['Sum', sum.toFixed(2)], ['Min', min.toFixed(2)], ['Max', max.toFixed(2)], ['Range', range.toFixed(2)], ['Mean', mean.toFixed(2)], // ['Mode', mode !== null ? mode.toFixed(2) : 'N/A'], ['Median', median.toFixed(2)], ['Standard Deviation (Sample)', standardDeviation.toFixed(2)], ['Standard Deviation (Population)', standardDeviationPopulation.toFixed(2)], ['Variance (Sample)', variance.toFixed(2)], ['Variance (Population)', variancePopulation.toFixed(2)], // ['Q1 (25th Percentile)', q1.toFixed(2)], // ['Q3 (75th Percentile)', q3.toFixed(2)], // ['<a href="https://www.qualitygurus.com/calculating-the-interquartile-range-a-quick-guide/" target="_blank">IQR</a>', iqr.toFixed(2)], ['Skewness', skewness.toFixed(2)], ['Kurtosis', kurtosis.toFixed(2)] ]; output.innerHTML = rows.map(([label, value]) => { return `<tr><td>\${label}</td><td>\${value}</td></tr>`; }).join(''); } document.addEventListener('DOMContentLoaded', calculateDescriptiveStatistics); ```

## 25 Essential Tools for Each Stage of the DMADV Approach

49 Courses on SALE!