# NAG CL Interfaceg01gec (prob_​beta_​noncentral)

Settings help

CL Name Style:

## 1Purpose

g01gec returns the probability associated with the lower tail of the noncentral beta distribution.

## 2Specification

 #include
 double g01gec (double x, double a, double b, double lambda, double tol, Integer max_iter, NagError *fail)
The function may be called by the names: g01gec, nag_stat_prob_beta_noncentral or nag_prob_non_central_beta_dist.

## 3Description

The lower tail probability for the noncentral beta distribution with parameters $a$ and $b$ and noncentrality parameter $\lambda$, $P\left(B\le \beta :a,b\text{;}\lambda \right)$, is defined by
 $P(B≤β:a,b;λ)=∑j=0∞e-λ/2 (λ/2) j! P(B≤β:a,b;0),$ (1)
where
 $P(B≤β : a,b;0)=Γ (a+b) Γ (a)Γ (b) ∫0βBa- 1(1-B)b- 1dB,$
which is the central beta probability function or incomplete beta function.
Recurrence relationships given in Abramowitz and Stegun (1972) are used to compute the values of $P\left(B\le \beta :a,b\text{;}0\right)$ for each step of the summation (1).
The algorithm is discussed in Lenth (1987).

## 4References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Lenth R V (1987) Algorithm AS 226: Computing noncentral beta probabilities Appl. Statist. 36 241–244

## 5Arguments

1: $\mathbf{x}$double Input
On entry: $\beta$, the deviate from the beta distribution, for which the probability $P\left(B\le \beta :a,b\text{;}\lambda \right)$ is to be found.
Constraint: $0.0\le {\mathbf{x}}\le 1.0$.
2: $\mathbf{a}$double Input
On entry: $a$, the first parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{a}}\le {10}^{6}$.
3: $\mathbf{b}$double Input
On entry: $b$, the second parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{b}}\le {10}^{6}$.
4: $\mathbf{lambda}$double Input
On entry: $\lambda$, the noncentrality parameter of the required beta distribution.
Constraint: $0.0\le {\mathbf{lambda}}\le -2.0\mathrm{log}\left(U\right)$, where $U$ is the safe range parameter as defined by X02AMC.
5: $\mathbf{tol}$double Input
On entry: the relative accuracy required by you in the results. If g01gec is entered with tol greater than or equal to $1.0$ or less than (see X02AJC), the value of is used instead.
See Section 7 for the relationship between tol and max_iter.
6: $\mathbf{max_iter}$Integer Input
On entry: the maximum number of iterations that the algorithm should use.
See Section 7 for suggestions as to suitable values for max_iter for different values of the arguments.
Suggested value: $500$.
Constraint: ${\mathbf{max_iter}}\ge 1$.
7: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_CONV
The solution has failed to converge in $⟨\mathit{\text{value}}⟩$ iterations. Consider increasing max_iter or tol. The returned value will be an approximation to the correct value.
NE_INT_ARG_LT
On entry, ${\mathbf{max_iter}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{max_iter}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_PROB_B_INIT
The required accuracy was not achieved when calculating the initial value of the beta distribution. You should try a larger value of tol. The returned value will be an approximation to the correct value. This error exit is no longer possible but is still documented for historical reasons.
NE_PROB_LIMIT
The probability is too close to $0.0$ or $1.0$ for the algorithm to be able to calculate the required probability. g01gec will return $0.0$ or $1.0$ as appropriate. This should be a reasonable approximation.
NE_REAL_ARG_CONS
On entry, ${\mathbf{a}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0<{\mathbf{a}}\le {10}^{6}$.
On entry, ${\mathbf{b}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0<{\mathbf{b}}\le {10}^{6}$.
On entry, ${\mathbf{lambda}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0\le {\mathbf{lambda}}\le -2.0\mathrm{log}\left(U\right)$, where $U$ is the safe range parameter as defined by X02AMC.
On entry, ${\mathbf{x}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0\le {\mathbf{x}}\le 1.0$.

## 7Accuracy

Convergence is theoretically guaranteed whenever $P\left(Y>{\mathbf{max_iter}}\right)\le {\mathbf{tol}}$ where $Y$ has a Poisson distribution with mean $\lambda /2$. Excessive round-off errors are possible when the number of iterations used is high and tol is close to machine precision. See Lenth (1987) for further comments on the error bound.

## 8Parallelism and Performance

g01gec is not threaded in any implementation.

The central beta probabilities can be obtained by setting ${\mathbf{lambda}}=0.0$.

## 10Example

This example reads values for several beta distributions and calculates and prints the lower tail probabilities until the end of data is reached.

### 10.1Program Text

Program Text (g01gece.c)

### 10.2Program Data

Program Data (g01gece.d)

### 10.3Program Results

Program Results (g01gece.r)