<< Beta Beta distfun_betainv >>

Distfun >> Beta > distfun_betacdf

distfun_betacdf

Beta CDF

Calling Sequence

p = distfun_betacdf ( x , a , b )
p = distfun_betacdf ( x , a , b , lowertail )

Parameters

x :

a 1x1 or nxm matrix of doubles, the outcome. Should be in the [0,1] interval.

a :

a 1x1 or nxm matrix of doubles, the first shape parameter. Should be positive.

b :

a 1x1 or nxm matrix of doubles, the second shape parameter. Should be positive.

lowertail :

a 1x1 matrix of booleans, the tail (default lowertail=%t). If lowertail is true (the default), then considers P(X<x) otherwise P(X>x).

p :

a 1x1 or nxm matrix of doubles, the probability

Description

Computes the Beta cumulated distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

Before applying the function definition, the following computations are done to push the input argument into the authorized range of values.

a = max(a,0)
b = max(b,0)

The function definition is:

where B is the beta function.

Examples

// Check expansion of a and b
computed = distfun_betacdf ( 0.1:0.2:0.9 , 2 , 2 )
expected = [0.0280,0.2160,0.5000,0.7840,0.9720]

// Check with expanded arguments
x = 0.1:0.2:0.9;
a = [2 3 4 5 6];
b = [5 4 3 2 1];
computed = distfun_betacdf ( x , a, b )
expected = [0.114265,0.25569,0.34375,0.420175,0.531441]

// Check bounds of x
computed = distfun_betacdf([-1 0 1 2],2,3)
expected = [0 0 1 1]

// Plot the function
a = [0.5 5 1 2 2];
b = [0.5 1 3 2 5];
cols = [1 2 3 4 5];
nf = size(cols,"*");
lgd = [];
scf();
for k = 1 : nf
x = linspace(0,1,1000);
y = distfun_betacdf ( x , a(k) , b(k) );
plot(x,y)
str = msprintf("a=%s, b=%s",..
string(a(k)),string(b(k)));
lgd($+1) = str;
end
h = gcf();
for k = 1 : nf
hk = h.children.children.children(nf - k + 1);
hk.foreground = cols(k);
end
xtitle("Beta CDF","x","P(X<x)");
legend(lgd);

// See upper tail
p = distfun_betacdf ( 0.1:0.2:0.9 , 2 , 2 )
q = distfun_betacdf ( 0.1:0.2:0.9 , 2 , 2 , %f )
p+q
// See an extreme case
distfun_betacdf ( 0.999 , 1 , 10 , %f )
expected = 1.e-30

Authors

<< Beta Beta distfun_betainv >>