ForHosting KIT · Math

Total sum of squares calculator

Measure the overall spread of a data set around its mean: for 2, 4, 6 and 8 the mean is 5 and the total sum of squares is 20. You also get the count and the mean to check the result. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Observed
2, 4, 6, 8
You get
N
4
Mean
5
Total sum squares
20

The total sum of squares measures the overall spread of observed numeric values around their arithmetic mean. For every observation, the calculator subtracts the mean, squares that deviation, and adds the squared deviations together. The result is also called the corrected total sum of squares and is commonly written as SST or TSS. It is the unnormalized quantity behind population variance, sample variance, analysis of variance, and several regression diagnostics. Supply a non-empty array of finite numbers and receive the observation count, mean, and total sum of squares. An empty array is rejected because its mean, and therefore its deviations, are undefined.

How the total sum of squares is calculated

Start with a non-empty array of observed values. The calculator first adds every value and divides that total by the number of observations to obtain the arithmetic mean. It then makes a second pass through the data.

For each observation, it subtracts the mean, squares the resulting deviation, and adds that squared deviation to a running total. In notation, the result is the sum of (x minus x-bar) squared over all observations. Squaring matters because deviations below and above the mean would otherwise cancel.

The calculation returns zero when every observation is identical, including when the array contains only one number, because every value then equals the mean. Larger results indicate more aggregate spread, but the magnitude depends on both the numerical scale and the number of observations. This implementation uses deterministic finite-number arithmetic and never calls a network service, reads the clock, or introduces randomness.

Inputs containing strings, null values, NaN, or infinity are rejected rather than silently converted, so the returned statistic always corresponds exactly to the numeric array supplied by the caller.

How to interpret TSS and relate it to variance

Total sum of squares is an unnormalized measure of dispersion. It answers how much squared distance the entire observed array has from its own mean, rather than how much squared distance belongs to an average observation. Population variance is obtained by dividing TSS by n, while the usual unbiased sample variance divides the same numerator by n minus one when at least two observations are available.

Keeping TSS separate is useful because many statistical formulas operate on this numerator before choosing a denominator. In analysis of variance, a total sum of squares can be partitioned into explained and residual components. In regression, the comparison between total and residual sums of squares helps form the coefficient of determination.

Units must be interpreted carefully: if observations are measured in meters, TSS is measured in square meters. It is therefore meaningful to compare results directly only when data sets use compatible units and scales. A larger array can also have a larger TSS simply because it contains more deviations.

For size-adjusted comparisons, use the appropriate variance or standard deviation after deciding whether the values represent a complete population or a sample.

ANOVA preparation

Compute the corrected total variability that can later be partitioned into between-group and within-group sums of squares.

Variance verification

Check the shared numerator behind population and sample variance before applying the denominator appropriate to the data.

Regression and spreadsheet testing

Create deterministic TSS values for regression diagnostics, teaching materials, automated tests, and spreadsheet formula audits.

What is the total sum of squares?

It is the sum of the squared differences between every observed value and the arithmetic mean of all observations.

Is total sum of squares the same as variance?

No. TSS is the numerator used by variance. Population variance divides it by n, while sample variance commonly divides it by n minus one.

Can the total sum of squares be zero?

Yes. It is zero when all observations are identical, including the special case of an array containing one value.

How do I calculate the total sum of squares by hand?

Find the mean, subtract it from each value, square each difference and add them up. For 2, 4, 6 and 8 the mean is 5, the squared deviations are 9, 1, 1 and 9, and the total is 20.

What units is the total sum of squares in?

In the square of your data's units. If the values are in meters, the result is in square meters, so only compare totals from data sets measured on the same scale.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/total-sum-squares

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/total-sum-squares \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"observed":[2,4,6,8]}'
{
  "observed": [
    2,
    4,
    6,
    8
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.total_sum_squares",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Input rules, validation, and practical uses

The order of observations does not affect the answer, and repeated values are retained because each occurrence is a genuine observation. Integers, decimals, negative values, and zero are accepted. For example, observations 2, 4, 6, and 8 have mean 5; their squared deviations are 9, 1, 1, and 9, so TSS is 20. Invalid requests are rejected before a meaningful statistic is returned. Send an object whose observed field is a JSON array containing at least one finite number. Empty arrays produce an invalid_input error, as do missing arrays and entries that are not finite JSON numbers. On success, the response includes n, the arithmetic mean, and total_sum_squares. These fields make the result easy to audit: you can confirm the count and mean before using TSS in a later formula. The browser calculation is free, while successful API requests use the published base price of $0.002 per item.

What happens when the observed array is empty?

The request fails with invalid_input because an empty array has no arithmetic mean and its total sum of squares is undefined.

How much does the calculator cost?

The browser calculator is free. A successful API request costs $0.002 per item; invalid input is not charged.

Read the full KIT documentation →