Is there a quantitative way to compare the distribution shape of different samples?

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?

-
univariate or multivariate sample? –  user603 Jun 22 '12 at 9:53
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! –  whuber Jun 22 '12 at 13:23
@whuber: alleluia! (i.e. thanks for formulating the comment so clearly). –  user603 Jun 22 '12 at 14:38
@user603: univariate sample –  Homunculus Reticulli Jun 22 '12 at 15:18
@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. –  Homunculus Reticulli Jun 22 '12 at 15:24

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 $$\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})}$$ where $\lambda_1\geq...\geq\lambda_p$ are the eigenvalues.

-
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. –  ttnphns Jun 22 '12 at 9:36
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. –  user603 Jun 22 '12 at 9:53
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"? –  ttnphns Jun 22 '12 at 10:03
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. –  user603 Jun 22 '12 at 10:19
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. –  ttnphns Jun 22 '12 at 14:14

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)