NAG Library Routine Document
g01abf (summary_2var)
1
Purpose
g01abf 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.
2
Specification
Fortran Interface
Integer, Intent (In) | :: | n | Integer, Intent (Inout) | :: | iwt, ifail | Real (Kind=nag_wp), Intent (In) | :: | x1(n), x2(n) | Real (Kind=nag_wp), Intent (Inout) | :: | wt(n) | Real (Kind=nag_wp), Intent (Out) | :: | res(13) |
|
C Header Interface
#include <nagmk26.h>
void |
g01abf_ (const Integer *n, const double x1[], const double x2[], Integer *iwt, double wt[], double res[], Integer *ifail) |
|
3
Description
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 g01abf.
The quantities calculated are:
(a) |
The sum of weights,
|
(b) |
The means,
|
(c) |
The corrected sums of squares and products
|
(d) |
The standard deviations
|
(e) |
The product-moment correlation coefficient
|
(f) |
The minimum and maximum elements in each of the two samples. |
(g) |
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 . |
4
References
None.
5
Arguments
- 1: – IntegerInput
-
On entry: , the number of pairs of observations.
Constraint:
.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: the observations from the first sample,
, for .
- 3: – Real (Kind=nag_wp) arrayInput
-
On entry: the observations from the second sample,
, for .
- 4: – IntegerInput/Output
-
On entry: indicates whether user-supplied weights are provided by you:
- Indicates that user-supplied weights are given in the array wt.
- Indicates that user-supplied weights are not given. In this case the routine assigns the value to each element of the weight array, wt.
On exit: is used to indicate the number of valid observations,
; see
Section 3(g), above.
- 5: – Real (Kind=nag_wp) arrayInput/Output
-
On entry: if weights are being supplied then the elements of
wt must contain the weights associated with the observations,
, for
.
Constraint:
if , , for .
On exit: if
, the elements of
wt are unchanged, otherwise each element of
wt will be assigned the value
.
- 6: – Real (Kind=nag_wp) arrayOutput
-
On exit: the elements of
res 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). |
- 7: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
The number of valid cases, , is . In this case standard deviation and product-moment correlation coefficient cannot be calculated.
-
On entry, .
Constraint:
, for
The number of valid cases, , is .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The method used is believed to be stable.
8
Parallelism and Performance
g01abf is not threaded in any implementation.
The time taken by g01abf increases linearly with .
10
Example
In the program below, NPROB determines the number of datasets to be analysed. For each analysis, a set of observations and, optionally, weights, is read and printed. After calling g01abf, all the calculated quantities are printed. In the example, there is one set of data, with (unweighted) pairs of observations.
10.1
Program Text
Program Text (g01abfe.f90)
10.2
Program Data
Program Data (g01abfe.d)
10.3
Program Results
Program Results (g01abfe.r)