9
$\begingroup$

I am conducting some research which involves visually/graphically observing the differences between the shapes of the distributions of different samples.

I would like to automate this process (at least somewhat), so that I can scale the number of samples I look at (as well as speeding things up, reducing human error etc.).

Is there a way to quantitatively describe/measure the shape of a distribution so that comparisons between shapes can be made algorithmically?

$\endgroup$
9
  • 1
    $\begingroup$ univariate or multivariate sample? $\endgroup$
    – user603
    Jun 22, 2012 at 9:53
  • 2
    $\begingroup$ Interested readers, and potential respondents, would like to know precisely what you mean by a "sample" and by the "shape" of a distribution. One reply already posted assumes a sample is a collection of $p$-tuples of real numbers and that "shape" is a similarity-invariant description of the resulting point cloud in $p$ dimensions. Many others, though, would take a "sample" to be a collection of numbers, its distribution to be their empirical distribution function, and its "shape" to be a description of the EDF up to changes of scale and location. Those are very different interpretations! $\endgroup$
    – whuber
    Jun 22, 2012 at 13:23
  • $\begingroup$ @whuber: alleluia! (i.e. thanks for formulating the comment so clearly). $\endgroup$
    – user603
    Jun 22, 2012 at 14:38
  • $\begingroup$ @user603: univariate sample $\endgroup$ Jun 22, 2012 at 15:18
  • 1
    $\begingroup$ @whuber: A few clarification of the terms I used in my question: By sample, I am referring to a collection of numbers. The samples don't all have the same number of points (which may complicate things further). By distribution, I am referring to the EDF, and by shape I am referring to a metric (ideally encapsulated by a single number), that captures measures of central tendency and dispersion. $\endgroup$ Jun 22, 2012 at 15:24

2 Answers 2

2
$\begingroup$

If the problem is uni-variate, then why not just do a KS test on the (centered, re scaled) vectors?

You can't use the associated pvalues (because the center and scale components have been determined by the data) but the D statistics gives a relative measure of the distance between the two vectors (In a nutshell, it's simply the Chebychev distance between the two CDF).

So, in R, it would be (assuming x and y are two vectors of potentially different lengths (each vector contains one of the sample whose shape of the distribution you want to compare).

For example, if $x\sim\mathcal{P}(\lambda)$ and $y\sim\mathcal{N}(\mu,\sigma^2)$:

#two distributions with different shape
y<-rnorm(100,0,3)
x<-rpois(100,1)
x_s<-(x-median(x))/mad(x)
y_s<-(y-median(y))/mad(y)
par(mfrow=c(2,1))
hist(y_s)
hist(x_s)
ks.test(x_s,y_s)

P.S. I left the original answer, because it seemed to be useful and frankly took me time to write. @Modo: let me know if it's better to remove it.

$\endgroup$
1
  • 1
    $\begingroup$ I'm not sure I understand what you mean. Could you please clarify? $\endgroup$ Jun 27, 2012 at 9:09
1
$\begingroup$

Sure, if the problem is multivariate:

Given a cloud of points with $p$ by $p$ covariance matrix $\varSigma$, the shape matrix of $\varSigma$ is defined as $\Gamma = |\varSigma|^{-1/p}\varSigma$. It follows that always $|\Gamma|=1$, and we can decompose the original matrix as $\varSigma = |\varSigma|^{1/p}\Gamma$. The square root of this scalar factor, $|\varSigma|^{1/2p}$, is called the scale component of $\varSigma$.

The shape matrix of the estimated scatter matrix S is computed analogously as $G = |S|^{-1/p}S$, and its scale component is $|S|^{1/2p}$.

The difference (distance) between two shape matrices $G_1$ and $G_2$ can be defined as \begin{equation} \mbox{D_s}(G_1,G_2) = \log\frac{\lambda_1(G^{-1/2}_{2} G_{1} G^{-1/2}_{2})} {\lambda_p(G^{-1/2}_{2} G_{1} G^{-1/2}_{2})} \end{equation} where $\lambda_1\geq...\geq\lambda_p$ are the eigenvalues.

$\endgroup$
11
  • 1
    $\begingroup$ What is p in your formulas? Is it the size of the square matrix (that is, number of variables for cov matrix and number of observations for scatter matrix)? Another thing, it'd be good if show how your formulas "degenerate" in univariate case, because the question author may have meant univariate distributions. $\endgroup$
    – ttnphns
    Jun 22, 2012 at 9:36
  • $\begingroup$ yes $p$ is the rank of the matrices (that's why there are $p$ eigen values). If the author meant univariate distributions, then my answer can't be used. $\endgroup$
    – user603
    Jun 22, 2012 at 9:53
  • 1
    $\begingroup$ I see. So, p is the number of positive eigenvalues, in both your cases, right? Your formulas are new to me. Could you please direct to the original source of them, to read more on the concept of "shape matrix"? $\endgroup$
    – ttnphns
    Jun 22, 2012 at 10:03
  • $\begingroup$ yes, both matrices need to be of same (and maximum) rank. I'm not sure i have a source handy --geometrically it is very intuitive-- but i will try to find one. $\endgroup$
    – user603
    Jun 22, 2012 at 10:19
  • 1
    $\begingroup$ All right. Admit your definition of scatter matrix as just SSCP matrix of centered data is more conventional. Still, I'd recomment you to explicitly define what you mean by "scatter matrix" in your answer. $\endgroup$
    – ttnphns
    Jun 22, 2012 at 14:14

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.