1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
// =============================================================================
// Tests for beta distribution
//
// Scilab Team
// Copyright INRIA
//
// =============================================================================
prec = 1.e-5;
A = 2;
B = 3;
bn = 1;
deff('[y]=Beta(x)','y=bn*(x^(A-1) * (1-x)^(B-1))');
bn = intg(0,1,Beta);
bn = 1/bn;
if norm(intg(0,1,Beta)-1)> prec then bugmes();quit;end
x = 0:0.1:1;
y = 1-x;
p1 = [];
for k=x
p1=[p1,intg(0,k,Beta)];
end
A = 2*ones(x);
B = 3*ones(x);
[p,q]=cdfbet('PQ',x,y,A,B);
if norm(p-p1) > prec then bugmes();quit;end
[x1,y1]=cdfbet('XY',A,B,p,q);
if norm(x-x1) > prec then bugmes();quit;end
if norm(y-y1) > prec then bugmes();quit;end
A1 = cdfbet('A',B,p,q,x,y);
// x=0 or x=1 do not work
if norm(A1(2:$-1)-A(2:$-1)) > prec then bugmes();quit;end
B1 = cdfbet('B',p,q,x,y,A);
if norm(B1(2:$-1)-B(2:$-1)) > prec then bugmes();quit;end
|