naginterfaces.library.stat.summary_2var(x1, x2, wt=None)[source]

summary_2var computes the means, standard deviations, corrected sums of squares and products, maximum and minimum values, and the product-moment correlation coefficient for two variables. Unequal weighting may be given.

For full information please refer to the NAG Library document for g01ab

x1float, array-like, shape

The observations from the first sample, , for .

x2float, array-like, shape

The observations from the second sample, , for .

wtNone or float, array-like, shape , optional

If weights are being supplied then the elements of must contain the weights associated with the observations, , for .

If weights are not supplied then may be None.


Is used to indicate the number of valid observations, ; see Notes (g).

resfloat, ndarray, shape

The elements of contain the following results:

mean of the first sample, ;

mean of the second sample, ;

standard deviation of the first sample, ;

standard deviation of the second sample, ;

corrected sum of squares of the first sample, ;

corrected sum of products of the two samples, ;

corrected sum of squares of the second sample, ;

product-moment correlation coefficient, ;

minimum of the first sample;

maximum of the first sample;

minimum of the second sample;

maximum of the second sample;

sum of weights, (, if , on entry).

(errno )

On entry, .

Constraint: .

(errno )

The number of valid cases, , is .

(errno )

On entry, .

Constraint: , for

(errno )

The number of valid cases, , is . In this case standard deviation and product-moment correlation coefficient cannot be calculated.


No equivalent traditional C interface for this routine exists in the NAG Library.

The data consist of two samples of observations, denoted by , and , for , with corresponding weights , for .

If no specific weighting is given, then each is set to in summary_2var.

The quantities calculated are:

  1. The sum of weights,

  2. The means,

  3. The corrected sums of squares and products

  4. The standard deviations

  5. The product-moment correlation coefficient

  6. The minimum and maximum elements in each of the two samples.

  7. The number of pairs of observations, , for which , i.e., the number of valid observations. The quantities in (d) and (e) above will only be computed if . All other items are computed if .