summaryrefslogtreecommitdiff
path: root/modules/statistics/tests/unit_tests/cdft.tst
blob: d3356285b87298ae6c29a3641b0d2db62e7b9fbf (plain)
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
34
35
36
37
38
39
40
41
42
43
44
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

// =============================================================================
// Tests for cdft() function
// using a table
// =============================================================================

// Run with test_run('statistics','cdft',['no_check_error_output']);

prec    = 1.e-5;

Tab     = [0.9,0.5,0.3,0.20,0.10,0.05,0.02];
Df      = [1,2,3,4,5,6,7];
Th      = [0.158,0.816,1.250,1.533,2.015,2.447,2.998];
[P1,Q1] = cdft("PQ",Th,Df);
[P2,Q2] = cdft("PQ",-Th,Df);

if norm(Tab-(Q1+P2)) > 0.1 then pause, end

[P,Q] = cdft("PQ",Th,Df);
Th1   = cdft("T",Df,P,Q);
Df1   = cdft("Df",P,Q,Th);

if norm(Th1-Th) > prec then pause,end
if norm(Df1-Df) > prec then pause,end

// IEEE support
// See http://bugzilla.scilab.org/show_bug.cgi?id=7296
Df       = 1;

T        = %inf; // Inf
[P,Q]    = cdft("PQ", T, Df);
assert_checkequal(P, 1);
assert_checkequal(Q, 0);

T        = %nan; // NaN
[P,Q]    = cdft("PQ", T, Df);
assert_checkequal(P, %nan);
assert_checkequal(Q, %nan);