forked from LanceOptican/lmoMatlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkPriors.m
76 lines (56 loc) · 2.64 KB
/
checkPriors.m
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
function checkPriors(data,options)
% this runs a short test whether the provided priors are functional
%function checkPriors(data,options)
% concretely the priors are evaluated for a 25 values on each dimension and
% a warning is issued for zeros and a error for nan and infs and negative
% values
if options.logspace
data(:, 1) = log(data(:, 1));
end
%% on threshold
% values chosen according to standard boarders
% at the borders it may be 0 -> a little inwards
dataspread = max(data(:, 1)) - min(data(:, 1)); % spread of the data
testValues = linspace(min(data(:, 1)) - .4 * dataspread, max(data(:, 1)) + .4 * dataspread,25); % threshold testvalues
testresult = options.priors{1}(testValues);
assert(all(isfinite(testresult)),'the prior you provided for the threshold returns non-finite values');
assert(all(testresult>=0), 'the prior you provided for the threshold returns negative values');
if any(testresult==0)
warning('the prior you provided for the threshold returns zeros');
end
%% on width
% values according to standard priors
testValues = linspace(1.1*min(diff(sort(unique(data(:, 1))))) , 2.9 * dataspread,25);
testresult = options.priors{2}(testValues);
assert(all(isfinite(testresult)),'the prior you provided for the width returns non-finite values');
assert(all(testresult>=0), 'the prior you provided for the width returns negative values');
if any(testresult==0)
warning('the prior you provided for the width returns zeros');
end
%% on lambda
% values 0 to .9
testValues = linspace(0,.9,25);
testresult = options.priors{3}(testValues);
assert(all(isfinite(testresult)),'the prior you provided for lambda returns non-finite values');
assert(all(testresult>=0), 'the prior you provided for lambda returns negative values');
if any(testresult==0)
warning('the prior you provided for the lambda returns zeros');
end
%% on gamma
% values 0 to .9
testValues = linspace(0,.9,25);
testresult = options.priors{4}(testValues);
assert(all(isfinite(testresult)),'the prior you provided for gamma returns non-finite values');
assert(all(testresult>=0), 'the prior you provided for gamma returns negative values');
if any(testresult==0)
warning('the prior you provided for the gamma returns zeros');
end
%% on sigma
% values 0 to .9
testValues = linspace(0,.9,25);
testresult = options.priors{5}(testValues);
assert(all(isfinite(testresult)),'the prior you provided for sigma returns non-finite values');
assert(all(testresult>=0), 'the prior you provided for sigma returns negative values');
if any(testresult==0)
warning('the prior you provided for the sigma returns zeros');
end