1 function [epsilon_test,epsilon_max,rb_sim_av_time,std_dev] = calculate_test_estimator(model, reduced_data)
3 % computes run-times and error estimators for a test sample of size
4 % 'N_test = 10' and collects statistical data on these magnitudes.
6 % Additionally, a scatter plot of the errors over the first two dimensions of
7 % the parameter domain is generated.
10 % epsilon_test: mean value of error estimators
11 % epsilon_max: max value of error estimators
12 % rb_sim_av_time: mean run-time of reduced simulations
13 % std_dev: standard deviation of error estimators
15 display('Calculating estimated test error');
16 N_test=25;%amount of Tests
17 rand(
'state',model.random_seed);
19 if isfield(model,
'N_test')
20 N_test = model.N_test;
22 disp(['Nr. of Test points: ',num2str(N_test)]);
23 random_mu = rand_uniform(N_test, model.mu_ranges);
27 est_error=zeros(1,N_test);
29 %Choose a mu from range by random choice
31 model = set_mu(model,mu);
32 %perform a reduced simulation and take the estiamated error of last
35 rb_sim_data = rb_simulation(model, reduced_data);
36 rb_sim_time = rb_sim_time + toc(rb_sim_timer);
37 %add error to total error
38 if isfield(rb_sim_data,'DeltaX')
39 est_error(i) = rb_sim_data.DeltaX(end);
40 elseif isfield(rb_sim_data,'Delta')
41 est_error(i) = rb_sim_data.Delta(end);
57 %calculate average estimated error
58 epsilon_test = sum(est_error)/N_test;
59 epsilon_max=max(est_error);
60 rb_sim_av_time = rb_sim_time/N_test;
61 std_dev=std(est_error);
62 %Visualisation of error map on parameter domain
64 sizeMu = size(random_mu);
67 % scatter3(random_mu(1,:),random_mu(2,:), random_mu(3,:),40,est_error,'filled');
69 elseif (sizeMu(1) ==2)
71 scatter(random_mu(1,:),random_mu(2,:),40,est_error,'filled');