# betainc

Incomplete beta function

## Syntax

```I = betainc(X,Z,W) I = betainc(X,Z,W,tail) ```

## Description

`I = betainc(X,Z,W)` computes the incomplete beta function for corresponding elements of the arrays `X`, `Z`, and `W`. The elements of `X` must be in the closed interval [0,1]. The arrays `Z` and `W` must be nonnegative and real. All arrays must be the same size, or any of them can be scalar.

`I = betainc(X,Z,W,tail)` specifies the tail of the incomplete beta function. Choices are:

 `'lower'` (the default) Computes the integral from `0` to `x` `'upper'` Computes the integral from `x` to `1`

These functions are related as follows:

`1-betainc(X,Z,W) = betainc(X,Z,W,'upper')`
Note that especially when the upper tail value is close to `0`, it is more accurate to use the` 'upper'` option than to subtract the `'lower'` value from `1`.

## Examples

collapse all

Compute the incomplete beta function corresponding to the elements of `Z` according to the parameters `X` and `W`.

```format longG X = 0.5; Z = (1:10)'; W = 3; I = betainc(X,Z,W)```
```I = 10×1 0.875 0.6875 0.5 0.34375 0.2265625 0.14453125 0.08984375 0.0546875 0.03271484375 0.019287109375 ```

collapse all

### Incomplete Beta Function

The incomplete beta function is

`${I}_{x}\left(z,w\right)=\frac{1}{B\left(z,w\right)}{\int }_{0}^{x}{t}^{z-1}{\left(1-t\right)}^{w-1}dt$`

where $B\left(z,w\right)$, the beta function, is defined as

`$B\left(z,w\right)={\int }_{0}^{1}{t}^{z-1}{\left(1-t\right)}^{w-1}dt=\frac{\Gamma \left(z\right)\Gamma \left(w\right)}{\Gamma \left(z+w\right)}$`

and $\Gamma \left(z\right)$ is the gamma function.