function kap8_3d()
% statistiscs with nQ(t), using replication/deletion
nRep = 100;
tEnd = 1500;
tA = 500;

t = (tA:tEnd)';
Y = zeros(nRep, 1);
S = zeros(nRep, 1);

load_system('singleserver4B');

for I=1:nRep
  NQ = runSingleserver4B(I, tEnd);
  fprintf('  Runde %3d\n', I)
  tIn = NQ.time;
  nQIn = NQ.signals.values;
  nQ = interp1(tIn, nQIn, t, 'previous');
  Y(I) = mean(nQ);
  S(I) = std(nQ);
end

% analysis of sample means Y
Ytot = mean(Y)
Stot = std(Y);
S2tot = Stot^2
alpha = 5/100;
z = tinv(1-alpha/2, nRep-1);
dS = z*Stot/sqrt(nRep);
fprintf('Konfidenzintervall: [%6.4f, %6.4f]\n', Ytot-dS, Ytot+dS)
