function realization=generate_realization(apriori,H0,H_tilde,C,regulator_parameters,system)

H=add_Hc_tilde0(H0,apriori,regulator_parameters); % nehlidam pozitivni definitnost !
realization=0;
system.S=zeros(1,3);
for o=1:regulator_parameters.horizont_simulace
    [u system]=simple_control(system,H(:,1));
    u=u+interpol(H,H_tilde,C);
    system.x=H(:,1)+sqrt(diag(H(:,2:5))).*randn(4,1);
    system.x=get_next(system,system.x,u);
    H=kalman_filter(H,u,system);
    realization=realization+u'*system.gamma*u+(system.x-system.x_opt)'*system.ksi*(system.x-system.x_opt);
end
end