function a_in = A_check(Ys,Xs,sigma_save,ih,f_xg,w_weight,lamdist,cvalue);

Zs = [Xs;Ys];
q = size(Xs,1);
n_bcd = size(sigma_save,3);
f_yx = NaN*zeros(n_bcd,1); % for joint density
for i = 1:n_bcd; 
    sigma = zeros(q+1,q+1);
    sigma(1:q,1:q) = sigma_save(1:q,1:q,i); 
    sigma(1:q,q+1) = sigma_save(1:q,q+ih,i);
    sigma(q+1,1:q) = sigma_save(q+ih,1:q,i);
    sigma(q+1,q+1) = sigma_save(q+ih,q+ih,i);
    sigma_inv = inv(sigma);
    f_yx(i) = den_invariant(Zs,sigma_inv);
end;

f_yx_lam = f_yx'*lamdist;
f_xg_w = f_xg'*w_weight;
a_in = f_yx_lam >= cvalue*f_xg_w;
