# Averaging a seek curve over a workload

A seek-time curve must be averaged over the distances actually traveled.
Evaluating the curve at the average distance can give a different answer.
The distinction matters before adding rotation, transfer or queueing time.

This packet is a dimensionless mathematical example, not a disk measurement
or a reproduction of a paper's experimental results. Its square-root curve
is chosen to expose the averaging operation, not to predict a real drive.

## Continuous positions

Let X and Y be independent uniform positions on a stroke normalized to [0, 1].
For D = |X - Y|, the distance density is f(d) = 2(1-d), for 0 <= d <= 1.
The triangular density follows by counting the two bands at distance d in
the unit square of ordered source-target pairs.

For the illustrative cost c(d) = sqrt(d):

| Quantity | Calculation | Value |
| --- | --- | --- |
| Mean distance | integral from 0 to 1 of 2d(1-d) dd | 1/3 |
| Mean cost | integral from 0 to 1 of 2sqrt(d)(1-d) dd | 8/15, about 0.5333 |
| Cost at mean distance | sqrt(1/3) | about 0.5774 |
| Relative difference | 100 x (sqrt(1/3) / (8/15) - 1) | about 8.3% |

The relative-difference denominator is the mean cost, not full-stroke cost.
The second integral is 2 x (2/3 - 2/5). No sampling or confidence interval is
involved: these are exact integrals, with rounded display values.

This direction is specific to the concave square-root curve. For c(d) = d^2,
the mean cost is 1/6, while the cost at mean distance is 1/9, which is lower.
For an affine curve a + bd, the two averages agree. An unknown physical
seek curve does not justify a universal error percentage or direction.

## Finite cylinders

For N >= 2 equally spaced cylinders numbered 0 through N-1, choose both endpoints
independently and uniformly. The full stroke is N-1 cylinder intervals.

| Distance k | Number of ordered pairs |
| --- | --- |
| 0 | N |
| 1 through N-1 | 2(N-k) |
| All distances | N^2 |

Weight each cost by that pair count divided by N^2. The exact normalized
mean distance is (N+1)/(3N), which approaches 1/3 as N grows. It is not
exactly one third for a finite cylinder population.

If the statistic counts only movements, exclude the N same-cylinder pairs
and divide by N(N-1). Then the mean normalized distance is
(N+1)/(3(N-1)). Conditioning changes both the population and the answer:
with two cylinders it becomes a full stroke instead of half a stroke.

The model assigns zero seek cost to zero distance; this does not imply zero
request latency. It includes no settling overhead, head-switch behavior,
rotational wait, transfer, controller work, queueing, cache or command overlap.

## Independence is not uniform coverage

Two requests independently choose position 0 or 0.1 with probability 1/2 each
within a unit stroke. Their four equally likely ordered pairs have distances
0, 0.1, 0.1 and 0. The mean is 0.05 of the stroke, not 1/3.
Thus independence alone does not establish the one-third-stroke result.
Neither does uniform logical-block selection establish uniform cylinder
selection on a zoned recording surface.

## Reproduce

Download these adjacent files:

- [model.mjs](./model.mjs): count-based calculation and JSON generator.
- [model.test.mjs](./model.test.mjs): independent pair enumeration and integration.
- [results.json](./results.json): generated continuous and six finite cases.

Run with Node.js 22 or later, without third-party packages:

```sh
node model.mjs --check
node --test model.test.mjs
```

Use `node model.mjs --write` to regenerate the JSON. The program rejects
noninteger cylinder counts, counts outside 2 through 10,000 and ambiguous
conditioning flags. Tests enumerate every ordered pair for N=2 through 40
and compare both population conventions against the count-based calculation.
Separate midpoint integration checks the continuous moments. The output's
extra decimal digits support regression tests, not physical precision.

## Reading and scope

Ruemmler and Wilkes, *An Introduction to Disk Drive Modeling*, IEEE Computer
27(3):17-29, March 1994, distinguishes averaging conventions and emphasizes
a seek-time-versus-distance profile. Its hardware parameters are historical:
[primary paper, OCR reprint](https://www.pdl.cmu.edu/Publications/HTML-Papers/DiskModeling/i.shtml).

Arpaci-Dusseau and Arpaci-Dusseau, *Operating Systems: Three Easy Pieces*,
chapter 37, version 1.10, explains seek phases, simultaneous platter motion,
zoning and scheduling:
[author-hosted textbook](https://pages.cs.wisc.edu/~remzi/OSTEP/file-disks.pdf).

These sources motivate the distinction; they do not report this packet's
8.3% illustrative result as a measured drive penalty. For performance work,
use a measured or specified curve and an explicitly described request
population. Read the [seek-time definition](https://hesela.dev/terms/seek-time/)
and [rotational-latency definition](https://hesela.dev/terms/rotational-latency/)
for the neighboring quantities.
