PCA for materials data · Part 3 of four ·

Mean, variance and covariance in materials measurements

We return to our specimens. Before we combine their measurements, we need to describe differences between specimens and relationships between measurement columns.

What does the mean tell us?

For S003, S005 and S006, the yield strengths are 292.4, 240.2 and 286.6 MPa. Their sum is 819.2 MPa. Dividing by three gives a mean of 273.07 MPa. Their differences from this mean are approximately +19.33, −32.87 and +13.53 MPa.

A mean summarizes a column, but does not tell us how different its entries are. Three specimens all having 273.07 MPa would have the same mean, but no differences between them.

\[\bar x=\frac{1}{n}\sum_{i=1}^{n}x_i.\]

Here \(x_i\) is the measurement for specimen \(i\), \(n\) is the number of specimens, and \(\bar x\) is the mean. The summation symbol means add the measurements. The mean has the same units as the measurement.

Mean grain size in our spreadsheet refers to averaging grain sizes within one specimen. Averaging that column across specimens is a second, different average.

Why do we subtract the mean?

Subtracting each column's mean is called centering. It lets us describe each specimen relative to the average specimen in the dataset. Centered values can be negative; a negative centered strength means below-average strength, not a physically negative strength.

How much do the values differ?

If we add the signed differences from the mean, positive and negative values cancel. To measure their size without this cancellation, we square each difference and add them. Sample variance divides that sum by one less than the number of specimens.

\[s_x^2=\frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar x)^2.\]

For the three yield strengths above, this variance is approximately 818.57 MPa². Its square root, the standard deviation, is approximately 28.61 MPa. Variance has squared measurement units; standard deviation has the original units.

Which measurements change together?

Across all 300 specimens, the correlation between yield strength and tensile strength is 0.967. They tend to increase together. Yield strength and elongation have correlation −0.875: higher yield strength tends to accompany lower elongation in this synthetic dataset.

Grain size and yield strength have correlation −0.958. Grain size and conductivity have correlation +0.551. Conductivity therefore contributes another relationship that we should examine, rather than leave out.

These are descriptions of this dataset, not proof of a physical cause. A correlation close to +1 indicates a strong positive linear relationship; one close to −1 indicates a strong negative linear relationship. A value near zero indicates little linear relationship, but does not rule out other relationships.

Covariance measures how signed deviations in two columns vary together:

\[s_{xy}=\frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar x)(y_i-\bar y).\]

Here \(x_i\) and \(y_i\) are two measurements on the same specimen. Their column means are \(\bar x\) and \(\bar y\). Covariance has the product of the two measurement units. Correlation divides covariance by the two standard deviations, making it dimensionless.

Why should we consider units?

S003's yield strength can be written as 292.4 MPa or 292,400,000 Pa. It is the same strength, but its numerical value changes by a million. Its numerical variance changes by a million squared. A PCA calculation based directly on these numbers can therefore change when we change units.

For this example, we subtract each column's mean and divide by its standard deviation. This is called standardization. Each resulting column is dimensionless, with mean zero and sample variance one.

\[z_i=\frac{x_i-\bar x}{s_x}.\]

Across all 300 specimens, mean yield strength is 244.56 MPa and its standard deviation is 31.96 MPa. For S003, the standardized value is (292.4 − 244.56)/31.96, approximately 1.497. For S005, it is approximately −0.136. These values describe their positions relative to the dataset's mean and standard deviation.

Standardizing is a choice, not a requirement of every PCA. Here it gives each feature equal initial variance. We must consider measurement reliability and our scientific question before making that choice for real data.

We now have a covariance matrix

We collect all the variances and covariances in a square table, with one row and one column for every feature. This is the covariance matrix. Our five features produce a 5 by 5 matrix. A diagonal entry is a feature's variance; an off-diagonal entry describes its covariance with another feature.

For standardized yield and tensile strengths, their two-feature portion is approximately:

\[\begin{pmatrix}1&0.967\\0.967&1\end{pmatrix}.\]

The diagonal ones are their standardized variances. The matching off-diagonal entries show that the two measurements tend to change together. We will use the complete five-feature matrix in the next article.

Acknowledgment and further reading

We consulted Jonathon Shlens's A Tutorial on Principal Component Analysis (2005, Version 2) while preparing this series. It explains PCA through changes of basis, covariance and the relationship with singular value decomposition. A later version is available on arXiv.