-
Notifications
You must be signed in to change notification settings - Fork 6
/
ruleNConvergence.m
44 lines (40 loc) · 1.2 KB
/
ruleNConvergence.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
function[MCsigExpVar, MCtrue_p, MCnSig] = ruleNConvergence( randExpVar, p, expVar )
%% Returns Monte Carlo convergence data for a significance level.
%
% [MCsigExpVar, MCtrue_p] = ruleNConvergence( randExpVar, p )
%
%
% ----- Inputs -----
%
% randExpVar: the random explained variances from a Rule N process
%
% p: The desired significance level for the test. p must be on the open
% interval (0, 1).
%
% expVar: The explained variance of data EOF modes.
%
%
% ----- Outputs -----
%
% MCsigExpVar: The explained variance significance threshold at each
% successive Monte Carlo iteration.
%
% MCtrue_p: The true significance level being tested at each successive
% Monte Carlo iteration.
%
% MCnSig: The number of significant modes at each successive Monte Carlo
% iteration.
%
% ----- Author -----
%
% Jonathan King, 2017, University of Arizona, [email protected]
% Get the significance threshold at each MC iteration
[MCsigExpVar, MCtrue_p] = mcthreshold( randExpVar, p, 'converge' );
% Preallocate
nMC = size(MCsigExpVar,1);
MCnSig = NaN( nMC, 1);
% Find the number of significant leading modes for each iteration
for k = 1:nMC
MCnSig(k) = find( expVar <= MCsigExpVar(k,:), 1, 'first') - 1;
end
end