Calculates values related to Extended Hanson--Koopmans tolerance bounds as described by Vangel (1994).

```
hk_ext_z(n, i, j, p, conf)
hk_ext_z_j_opt(n, p, conf)
```

- n
the sample size

- i
the first order statistic (1 <= i < j)

- j
the second order statistic (i < j <= n)

- p
the content of the tolerance bound (normally 0.90 or 0.99)

- conf
the confidence level (normally 0.95)

For `hk_ext_z`

, the return value is a numeric value representing
the parameter z (denoted as k in CMH-17-1G).

For `hk_ext_z_j_opt`

, the return value is named list containing
`z`

and `k`

. The former is the value of z, as defined by
Vangel (1994), and the latter is the corresponding order statistic.

Hanson (1964) presents a nonparametric method for determining tolerance bounds based on consecutive order statistics. Vangel (1994) extends this method using non-consecutive order statistics.

The extended Hanson--Koopmans method calculates a tolerance bound
(basis value) based on two order statistics and a weighting value
`z`

. The value of `z`

is based on the sample size, which
order statistics are selected, the desired content of the tolerance
bond and the desired confidence level.

The function `hk_ext_z`

calculates the weighting variable `z`

based on selected order statistics `i`

and `j`

. Based on this
value `z`

, the tolerance bound can be calculated as:

$$S = z X_{(i)} + (1 - z) X_{(j)}$$

Where \(X_{(i)}\) and \(X_{(j)}\) are the `i-th`

and `j-th`

ordered observation.

The function `hk_ext_z_j_opt`

determines the value of `j`

and
the corresponding value of `z`

, assuming `i=1`

. The value
of `j`

is selected such that the computed tolerance limit is
nearest to the desired population quantile for a standard normal
distribution when the order statistics are equal to the expected
value of the order statistics for the standard normal distribution.

M. Vangel, “One-Sided Nonparametric Tolerance Limits,” Communications in Statistics - Simulation and Computation, vol. 23, no. 4. pp. 1137–1154, 1994.

D. L. Hanson and L. H. Koopmans, “Tolerance Limits for the Class of Distributions with Increasing Hazard Rates,” The Annals of Mathematical Statistics, vol. 35, no. 4. pp. 1561–1570, 1964.

```
# The factors from Table 1 of Vangel (1994) can be recreated
# using the hk_ext_z function. For the sample size n=21,
# the median is the 11th ordered observation. The factor
# required for calculating the tolerance bound with a content
# of 0.9 and a confidence level of 0.95 based on the median
# and first ordered observation can be calculated as follows.
hk_ext_z(n = 21, i = 1, j = 11, p = 0.9, conf = 0.95)
#> [1] 1.204806
## [1] 1.204806
# The hk_ext_z_j_opt function can be used to refine this value
# of z by finding an optimum value of j, rather than simply
# using the median. Here, we find that the optimal observation
# to use is the 10th, not the 11th (which is the median).
hk_ext_z_j_opt(n = 21, p = 0.9, conf = 0.95)
#> $z
#> [1] 1.217717
#>
#> $j
#> [1] 10
#>
## $z
## [1] 1.217717
##
## $j
## [1] 10
```