function s = BR_get_samp(P)
%

r = rand;

if r<P(1)
    s = [0,0,0,0,0];
elseif r<sum(P(1:2))
    s = [0,0,0,0,1];
elseif r<sum(P(1:3))
    s = [0,0,0,1,0];
elseif r<sum(P(1:4))
    s = [0,0,0,1,1];
elseif r<sum(P(1:5))
    s = [0,0,1,0,0];
elseif r<sum(P(1:6))
    s = [0,0,1,0,1];
elseif r<sum(P(1:7))
    s = [0,0,1,1,0];
elseif r<sum(P(1:8))
    s = [0,0,1,1,1];
elseif r<sum(P(1:9))
    s = [0,1,0,0,0];
elseif r<sum(P(1:10))
    s = [0,1,0,0,1];
elseif r<sum(P(1:11))
    s = [0,1,0,1,0];
elseif r<sum(P(1:12))
    s = [0,1,0,1,1];
elseif r<sum(P(1:13))
    s = [0,1,1,0,0];
elseif r<sum(P(1:14))
    s = [0,1,1,0,1];
elseif r<sum(P(1:15))
    s = [0,1,1,1,0];
elseif r<sum(P(1:16))
    s = [0,1,1,1,1];
elseif r<sum(P(1:17))
    s = [1,0,0,0,0];
elseif r<sum(P(1:18))
    s = [1,0,0,0,1];
elseif r<sum(P(1:19))
    s = [1,0,0,1,0];
elseif r<sum(P(1:20))
    s = [1,0,0,1,1];
elseif r<sum(P(1:21))
    s = [1,0,1,0,0];
elseif r<sum(P(1:22))
    s = [1,0,1,0,1];
elseif r<sum(P(1:23))
    s = [1,0,1,1,0];
elseif r<sum(P(1:24))
    s = [1,0,1,1,1];
elseif r<sum(P(1:25))
    s = [1,1,0,0,0];
elseif r<sum(P(1:26))
    s = [1,1,0,0,1];
elseif r<sum(P(1:27))
    s = [1,1,0,1,0];
elseif r<sum(P(1:28))
    s = [1,1,0,1,1];
elseif r<sum(P(1:29))
    s = [1,1,1,0,0];
elseif r<sum(P(1:30))
    s = [1,1,1,0,1];
elseif r<sum(P(1:31))
    s = [1,1,1,1,0];
else
    s = [1,1,1,1,1];
end
