g01ae constructs a frequency distribution of a variable, according to either user-supplied, or method-calculated class boundary values.

# Syntax

C# |
---|

public static void g01ae( int n, int k, double[] x, int iclass, double[] cb, int[] ifreq, out double xmin, out double xmax, out int ifail ) |

Visual Basic |
---|

Public Shared Sub g01ae ( _ n As Integer, _ k As Integer, _ x As Double(), _ iclass As Integer, _ cb As Double(), _ ifreq As Integer(), _ <OutAttribute> ByRef xmin As Double, _ <OutAttribute> ByRef xmax As Double, _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void g01ae( int n, int k, array<double>^ x, int iclass, array<double>^ cb, array<int>^ ifreq, [OutAttribute] double% xmin, [OutAttribute] double% xmax, [OutAttribute] int% ifail ) |

F# |
---|

static member g01ae : n : int * k : int * x : float[] * iclass : int * cb : float[] * ifreq : int[] * xmin : float byref * xmax : float byref * ifail : int byref -> unit |

#### Parameters

- n
- Type: System..::..Int32
*On entry*: $n$, the number of observations.*Constraint*: ${\mathbf{n}}\ge 1$.

- k
- Type: System..::..Int32
*On entry*: $k$, the number of classes desired in the frequency distribution. Whether or not class boundary values are user-supplied, k must include the two extreme classes which stretch to $\pm \infty $.*Constraint*: ${\mathbf{k}}\ge 2$.

- x
- Type: array<System..::..Double>[]()[][]An array of size [n]
*On entry*: the sample of observations of the variable for which the frequency distribution is required, ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$. The values may be in any order.

- iclass
- Type: System..::..Int32
*On entry*: indicates whether class boundary values are to be calculated within g01ae, or are supplied by you.If ${\mathbf{iclass}}=0$, then the class boundary values are to be calculated within the method.If ${\mathbf{iclass}}=1$, they are user-supplied.*Constraint*: ${\mathbf{iclass}}=0$ or $1$.

- cb
- Type: array<System..::..Double>[]()[][]An array of size [k]
*On entry*: if ${\mathbf{iclass}}=0$, then the elements of cb need not be assigned values, as g01ae calculates $k-1$ class boundary values.If ${\mathbf{iclass}}=1$, the first $k-1$ elements of cb must contain the class boundary values you supplied, in ascending order.In both cases, the element ${\mathbf{cb}}\left[k-1\right]$ need not be assigned, as it is not used in the method.*Constraint*: if ${\mathbf{iclass}}=1$, ${\mathbf{cb}}\left[\mathit{i}-1\right]<{\mathbf{cb}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,k-2$.

- ifreq
- Type: array<System..::..Int32>[]()[][]An array of size [k]
*On exit*: the elements of ifreq contain the frequencies in each class, ${f}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,k$. In particular ${\mathbf{ifreq}}\left[0\right]$ contains the frequency of the class up to ${\mathbf{cb}}\left[0\right]$, ${f}_{1}$, and ${\mathbf{ifreq}}\left[k-1\right]$ contains the frequency of the class greater than ${\mathbf{cb}}\left[k-2\right]$, ${f}_{k}$.

- xmin
- Type: System..::..Double%
*On exit*: the smallest value in the sample, $a$.

- xmax
- Type: System..::..Double%
*On exit*: the largest value in the sample, $b$.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

The data consists of a sample of $n$ observations of a continuous variable, denoted by ${x}_{i}$, for $\mathit{i}=1,2,\dots ,n$. Let $a=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({x}_{1},\dots ,{x}_{n}\right)$ and $b=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({x}_{1},\dots ,{x}_{n}\right)$.

g01ae constructs a frequency distribution with $k\left(>1\right)$ classes denoted by ${f}_{i}$, for $\mathit{i}=1,2,\dots ,k$.

The boundary values may be either user-supplied, or method-calculated, and are denoted by ${y}_{j}$, for $\mathit{j}=1,2,\dots ,k-1$.

If the boundary values of the classes are to be method-calculated, then they are determined in one of the following ways:

(a) | if $k>2$, the range of $x$ values is divided into $k-2$ intervals of equal length, and two extreme intervals, defined by the class boundary values ${y}_{1},{y}_{2},\dots ,{y}_{k-1}$; |

(b) | if $k=2$, ${y}_{1}=\frac{1}{2}\left(a+b\right)$. |

However formed, the values ${y}_{1},\dots ,{y}_{k-1}$ are assumed to be in ascending order. The class frequencies are formed with

- ${f}_{1}=\text{}$ the number of $x$ values in the interval $\left(-\infty ,{y}_{1}\right)$
- ${f}_{i}=\text{}$ the number of $x$ values in the interval $\left[{y}_{i-1},{y}_{i}\right)$, $\text{\hspace{1em}}i=2,\dots ,k-1$
- ${f}_{k}=\text{}$ the number of $x$ values in the interval $\left[{y}_{k-1},\infty \right)$,

If a frequency distribution is required for a discrete variable, then it is suggested that you supply the class boundary values; method-calculated boundary values may be slightly imprecise (due to the adjustment of ${y}_{1}$ and ${y}_{k-1}$ outlined above) and cause values very close to a class boundary to be assigned to the wrong class.

# References

None.

# Error Indicators and Warnings

Errors or warnings detected by the method:

- ${\mathbf{ifail}}=1$
On entry, ${\mathbf{k}}<2$.

- ${\mathbf{ifail}}=2$
On entry, ${\mathbf{n}}<1$.

- ${\mathbf{ifail}}=3$
On entry, the user-supplied class boundary values are not in ascending order.

# Accuracy

The method used is believed to be stable.

# Parallelism and Performance

None.

# Further Comments

# Example

This example summarises a number of datasets. For each dataset the sample observations and optionally class boundary values are read. g01ae is then called and the frequency distribution and largest and smallest observations printed.

Example program (C#): g01aee.cs