File size: 5,101 Bytes
5ab75a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
classdef (SharedTestFixtures = { ...
        matlab.unittest.fixtures.PathFixture('..')}) ...
        DetermineOptimalScaleFactor_UnitTest < matlab.unittest.TestCase
%% Series of Tests intended to test the 2D probability of Collision Calculation at TCA

    methods (Test)
        function test01(testCase) % Hejduk Provided Test Case 1
            % Normal Distribution with appropriately scaled covariances
            Accuracy        = 0.05; 
            expScaleFactor = 1;
            % ID of Test Event
            FileName = fullfile('InputFiles','CovarianceRealismTestInput01.mat');
            load(FileName,'Covariances','Residuals');
            
            Options.NumberOfTrials=10000;
            Options.TrialSampleSize=50;
            Options.SignificanceLevel=0.02;
            FigureOffset=0;
            TestStat=1;
            
            % Calculate Scale Factors
            actScaleFactor=DetermineOptimalScaleFactor(Residuals,Covariances,Options,TestStat,FigureOffset);

            % Verify Results
            testCase.verifyEqual(actScaleFactor,expScaleFactor,'RelTol',Accuracy);
        end
        
        function test02(testCase) % Hejduk Provided Test Case 2
            % Normal Distribution with Oversized Covariances
            Accuracy        = 0.05; 
            % Set expected normality test results to 0.14 to account for
            % covariance scaling
            expScaleFactor = 0.25;
            % ID of Test Event
            FileName = fullfile('InputFiles','CovarianceRealismTestInput02.mat');
            load(FileName,'Covariances','Residuals');
            
            Options.NumberOfTrials=10000;
            Options.TrialSampleSize=50;
            Options.SignificanceLevel=0.02;
            FigureOffset=0;
            TestStat=1;
            
            % Calculate Scale Factors
            actScaleFactor=DetermineOptimalScaleFactor(Residuals,Covariances,Options,TestStat,FigureOffset);

            % Verify Results
            testCase.verifyEqual(actScaleFactor,expScaleFactor,'RelTol',Accuracy);
        end
        
        function test03(testCase) % Hejduk Provided Test Case 3
            % Normal Distribution with Undersized Covariances
            Accuracy        = 0.05; 
            % Set expected normality test results to above lower bound to account for
            % covariance scaling
            expScaleFactor = 3;
            % ID of Test Event
            FileName = fullfile('InputFiles','CovarianceRealismTestInput03.mat');
            load(FileName,'Covariances','Residuals');
            
            Options.NumberOfTrials=10000;
            Options.TrialSampleSize=50;
            Options.SignificanceLevel=0.02;
            FigureOffset=0;
            TestStat=1;
            
            % Calculate Scale Factors
            actScaleFactor=DetermineOptimalScaleFactor(Residuals,Covariances,Options,TestStat,FigureOffset);
            
            % Verify Results
            testCase.verifyEqual(actScaleFactor,expScaleFactor,'RelTol',Accuracy);
        end
        
        function test04(testCase) % Hejduk Provided Test Case 4
            % T-Distribution
            Accuracy        = 0.05; 
            % Set expected normality test results to above lower bound to account for
            % covariance scaling
            expScaleFactor = 0.54;
            % ID of Test Event
            FileName = fullfile('InputFiles','CovarianceRealismTestInput04.mat');
            load(FileName,'Covariances','Residuals');
            
            Options.NumberOfTrials=10000;
            Options.TrialSampleSize=50;
            Options.SignificanceLevel=0.02;
            FigureOffset=0;
            TestStat=1;
            
            % Calculate Scale Factors
            actScaleFactor=DetermineOptimalScaleFactor(Residuals,Covariances,Options,TestStat,FigureOffset);
            
            % Verify Results
            testCase.verifyEqual(actScaleFactor,expScaleFactor,'RelTol',Accuracy);
        end
        
        function test05(testCase) % Hejduk Provided Test Case 5
            % exponential distribution
            Accuracy        = 0.05; 
            % Set expected normality test results to above lower bound to account for
            % covariance scaling
            expScaleFactor = 1.26;
            % ID of Test Event
            FileName = fullfile('InputFiles','CovarianceRealismTestInput05.mat');
            load(FileName,'Covariances','Residuals');
            
            Options.NumberOfTrials=10000;
            Options.TrialSampleSize=50;
            Options.SignificanceLevel=0.02;
            FigureOffset=0;
            TestStat=1;
            
            % Calculate Scale Factors
            actScaleFactor=DetermineOptimalScaleFactor(Residuals,Covariances,Options,TestStat,FigureOffset);
            
            % Verify Results
            testCase.verifyEqual(actScaleFactor,expScaleFactor,'RelTol',Accuracy);
        end
        
    end 
end