function [KB,KB00,KB01,KB10,KB11] = BR_incon_rand(n,ms,msl,num_samps)
%

THRESH = 0.001;

KB = BR_gen_test_KB_gen(n,ms,msl);
num_sentences = length(KB);

KB00 = [];
KB01 = [];
KB10 = [];
KB11 = [];

for s = 1:num_samps
    p = rand(num_sentences,1);
    for c = 1:num_sentences
        KB(c).prob = p(c);
    end
    P = BR_Nilsson(KB);
    P_sum = sum(P);
    ps = zeros(num_sentences,1);
    conditions = zeros(num_sentences+1,1);
    conditions(1) = abs(P_sum-1)<THRESH;
    for c = 1:num_sentences
        ps(c) = BR_Nilsson_query_clause(KB(c).clauses,P);
        conditions(c+1) = abs(ps(c)-KB(c).prob)<THRESH;
    end
    X = BR_linprog(KB);
    if min(conditions)==0&isempty(X)
        KB00 = [KB00;p'];
    end
    if min(conditions)==0&~isempty(X)
        KB01 = [KB01;p'];
    end
    if min(conditions)==1&isempty(X)
        KB10 = [KB10;p'];
    end
    if min(conditions)==1&~isempty(X)
        KB11 = [KB11;p'];
    end
end
