# procrustes

Procrustes analysis

## Syntax

```d = procrustes(X,Y) [d,Z] = procrustes(X,Y) [d,Z,transform] = procrustes(X,Y) [...] = procrustes(...,'scaling',flag) [...] = procrustes(...,'reflection',flag) ```

## Description

`d = procrustes(X,Y)` determines a linear transformation (translation, reflection, orthogonal rotation, and scaling) of the points in matrix `Y` to best conform them to the points in matrix `X`. The goodness-of-fit criterion is the sum of squared errors. `procrustes` returns the minimized value of this dissimilarity measure in `d`. `d` is standardized by a measure of the scale of `X`, given by:

`sum(sum((X-repmat(mean(X,1),size(X,1),1)).^2,1))`

That is, the sum of squared elements of a centered version of `X`. However, if `X` comprises repetitions of the same point, the sum of squared errors is not standardized.

`X` and `Y` must have the same number of points (rows), and `procrustes` matches `Y(i)` to `X(i)`. Points in `Y` can have smaller dimension (number of columns) than those in `X`. In this case, `procrustes` adds columns of zeros to `Y` as necessary.

`[d,Z] = procrustes(X,Y)` also returns the transformed `Y` values.

`[d,Z,transform] = procrustes(X,Y)` also returns the transformation that maps `Y` to `Z`. `transform` is a structure array with fields:

• `c` — Translation component

• `T` — Orthogonal rotation and reflection component

• `b` — Scale component

That is:

```c = transform.c; T = transform.T; b = transform.b; Z = b*Y*T + c;```

`[...] = procrustes(...,'scaling',flag)`, when `flag` is `false`, allows you to compute the transformation without a scale component (that is, with `b` equal to `1`). The default `flag` is `true`.

`[...] = procrustes(...,'reflection',flag)`, when `flag` is `false`, allows you to compute the transformation without a reflection component (that is, with `det(T)` equal to `1`). The default `flag` is `'best'`, which computes the best-fitting transformation, whether or not it includes a reflection component. A `flag` of `true` forces the transformation to be computed with a reflection component (that is, with `det(T)` equal to `-1`)

## Examples

collapse all

Generate the sample data in two dimensions.

```rng('default') n = 10; X = normrnd(0,1,[n 2]);```

Rotate, scale, translate, and add some noise to sample points.

```S = [0.5 -sqrt(3)/2; sqrt(3)/2 0.5]; Y = normrnd(0.5*X*S+2,0.05,n,2);```

Conform `Y` to `X` using procrustes analysis.

`[d,Z,tr] = procrustes(X,Y);`

Plot the original `X` and `Y` with the transformed `Y` .

`plot(X(:,1),X(:,2),'rx',Y(:,1),Y(:,2),'b.',Z(:,1),Z(:,2),'bx');`

## References

[1] Kendall, David G. “A Survey of the Statistical Theory of Shape.” Statistical Science. Vol. 4, No. 2, 1989, pp. 87–99.

[2] Bookstein, Fred L. Morphometric Tools for Landmark Data. Cambridge, UK: Cambridge University Press, 1991.

[3] Seber, G. A. F. Multivariate Observations. Hoboken, NJ: John Wiley & Sons, Inc., 1984.