In Chapter 2 Section 2.1.4 of An Introduction to Statistical Learning (James et al, 2013), the assertion is made that "...if there are p variables in our data set, then p(p-1)/2 distinct scatter plots can be made...".

Would you please clarify how this is derived?

  • $\begingroup$ You have p variables to choose for the x-axis and then p-1 for the y-axis. This gives you p(p-1) plots but the order really doesn't matter. So you divide by 2 to get the number of distinct pairs. Note that you have included variable 1 (say) for x-axis and variable 2 for the y-axis and also variable 2 for the x-axis and variable 1 for the y-axis. That is why you have to divide by 2. $\endgroup$ Jul 30, 2017 at 11:46

1 Answer 1


Assuming you don't count a plot of $X_3$ vs $X_6$ as distinct from a plot of $X_6$ vs $X_3$ and further assuming you don't care to plot a variable vs itself, then you want the number of distinct pairs $i,j$ for $i<j$ and $i$ and $j$ integers between $1$ and $p$ exclusive.

There's $p \times p$ pairs $(i,j)$. We remove the $i=j$ cases, which removes $p$ of those, leaving $p \times (p-1)$.

diagram of pairs 1 ≤ i < j ≤ p

We then take the half that have $i<j$ (the other half have $i>j$ but they're the same set of plots with axes interchanged). This leaves $\frac12 p\times (p-1)$

Alternatively you could just look at it as the number of ways of choosing two distinct variables out of $p$, without regard to order, which is ${p \choose 2}=p(p-1)/2$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.