# Prediction: drift property

> The drift read-only property of the Prediction interface summarizes recent mispredictions and gives a verdict on them.

The **`drift`** read-only property of the [`Prediction`](/docs/client/prediction) interface is a summary of the mispredictions of about the last second, so you can tell a stepper that disagrees with the room from a few late inputs.

## Value

An object with these properties:

`rate`
: A number from 0 to 1: the share of replays that mispredicted.

`average`
: A number: the size of mispredictions, with matched replays counting 0.

`peak`
: A number: the largest recent misprediction, falling to a tenth within a second.

`last`
: A number: the size of the last misprediction, kept until the next one, and 0 before the first.

`fields`
: A read-only array of strings: the fields of the last misprediction.

`verdict`
: A string, from `rate`:

  `"matched"`
  : `rate` is under 1%. The prediction ran what the room ran.

  `"jitter"`
  : `rate` is from 1% to under 50%: occasional mispredictions, which `render()` smooths, such as an input that reached the room after its tick.

  `"diverging"`
  : `rate` is 50% or more, so the stepper and the room disagree: a step that reads something besides `world`, `inputs`, `dt` and `tick`, room code that moves the predicted entity outside the stepper, or a rule only `onTick()` applies.

## Description

A misprediction's size is the largest of its numeric fields' deltas, as the [`mispredict` event](/docs/client/prediction/mispredict-event) reports them, and the angle in radians a `quat` field was off by. Fields of other types count toward `rate` with no size.

The averages are kept per room tick with a half-second time constant, whatever the tick rate. Ticks with no state update count as matched once half a second has passed, so the verdict returns to `"matched"` in a room that goes quiet. [`snap()`](/docs/client/prediction/snap), a misprediction [`render()`](/docs/client/prediction/render) drops for `snapDistance`, a reconnect and a new room generation reset it.

Pass `warnOnDivergence: true` to [`RoomClient.predict()`](/docs/client/room-client/predict) to log a console warning when the verdict turns `"diverging"`.

## Examples

### Showing a drift warning while you develop

A development build shows which fields diverge, so the stepper's author can find the rule the room applies outside it.

```ts
// drift-badge.ts
import type { Prediction } from "@irtio/client";

export function driftBadge(me: Prediction<unknown>): string {
  const { verdict, rate, fields } = me.drift;
  if (verdict === "matched") return "";
  return `${verdict}: ${Math.round(rate * 100)}% of replays missed ${fields.join(", ")}`;
}
```

## See also

- [`mispredict` event](/docs/client/prediction/mispredict-event)
- [`Prediction.mispredictions`](/docs/client/prediction/mispredictions)
- [Drift](/docs/client/guides/prediction#drift) in Client prediction
- [Dev tools](/docs/tools/dev-tools#prediction-drift), for the drift panel
