Compare the relative variability of different datasets.
Calculation Results
Count (n):0
Mean (μ):0
Std. Deviation (σ):0
Variance (σ²):0
COEFFICIENT OF VARIATION (CV)
0%
Please enter at least two valid numbers to calculate the coefficient of variation.
Understanding the Coefficient of Variation (CV)
The Coefficient of Variation (CV), also known as relative standard deviation (RSD), is a standardized measure of dispersion of a probability distribution or frequency distribution. It is often expressed as a percentage and is defined as the ratio of the standard deviation to the mean.
Why Use the CV Instead of Standard Deviation?
Standard deviation is an absolute measure, meaning it is expressed in the same units as the data. If you are comparing the variability of weight (kg) and height (cm), or two stock portfolios with vastly different average prices, the standard deviation alone doesn't tell the full story. The CV allows you to compare the degree of variation from one data series to another, even if the means are drastically different.
The Mathematical Formula
CV = (σ / μ) * 100
Where:
σ = Standard Deviation
μ = Mean (Average)
Practical Example: Portfolio Analysis
Imagine you are comparing two investment funds:
Fund A: Average return of 10% with a standard deviation of 2%.
Fund B: Average return of 5% with a standard deviation of 1.5%.
Calculations:
Fund A CV: (2 / 10) * 100 = 20%
Fund B CV: (1.5 / 5) * 100 = 30%
Even though Fund B has a lower absolute standard deviation, Fund A is more stable relative to its expected return because it has a lower CV.
function performCVCalculation() {
var inputVal = document.getElementById('datasetInput').value;
var resultBox = document.getElementById('cv-results-box');
var errorBox = document.getElementById('cv-error');
// Clean input: split by comma, space, or newline, and filter out non-numeric values
var numbers = inputVal.split(/[\s,]+/).filter(function(item) {
return item !== "" && !isNaN(parseFloat(item)) && isFinite(item);
}).map(Number);
if (numbers.length < 2) {
resultBox.style.display = 'none';
errorBox.style.display = 'block';
return;
}
errorBox.style.display = 'none';
// 1. Calculate Mean
var sum = 0;
for (var i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
var mean = sum / numbers.length;
// 2. Calculate Variance
var squareDiffs = 0;
for (var j = 0; j < numbers.length; j++) {
var diff = numbers[j] – mean;
squareDiffs += diff * diff;
}
var isPopulation = document.querySelector('input[name="calcType"]:checked').value === 'population';
var variance = isPopulation ? (squareDiffs / numbers.length) : (squareDiffs / (numbers.length – 1));
// 3. Calculate Standard Deviation
var stdDev = Math.sqrt(variance);
// 4. Calculate CV
var cv = 0;
if (mean !== 0) {
cv = (stdDev / Math.abs(mean)) * 100;
}
// Display Results
document.getElementById('resCount').innerText = numbers.length;
document.getElementById('resMean').innerText = mean.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 4});
document.getElementById('resSD').innerText = stdDev.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 4});
document.getElementById('resVar').innerText = variance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 4});
document.getElementById('resCV').innerText = cv.toFixed(2) + "%";
resultBox.style.display = 'block';
}