My first idea was to make a cycle like this:
for j=1:m
for i=1:n
r=rand;
if r <= p
B(i)=1;
else
B(i)=0;
end
end
k(j)=B(1);
end
what the part that says k(j)=B(1) is trying to do it's to count all the successes (1s) of the first iteration of the cycle n, but pretty much to no avail. Any ideas?