I am trying to simulate a simple bernuli simulation and also a simple geometric simulation on matlab and since I am new to matlab it seems a bit difficult. I have been using this to understand it better http://www.academia.edu/1722549/Useful_distributions_using_MATLAB but I Havent been able to make a good simulation so far.Can some help me or show me a good tutorial. thank you.
NEW EDIT: answer from here: this is my own asnwer that I try to com up with is it correct:
If we want to simulate Bernoulli distribution in Matlab, we can simply use random number generator rand to simulate a Bernoulli experiment. In this case we try to simulate tossing a coin 4 times with p = 0.5:
>> p = 0.5;
>> rand(1,4) < p
ans =
1 1 1 0
Using function rand, it returns values distributed between 0 and 1. By using “ < “, every value that is less than 0.5 is a success and therefore it prints 1 for that value; and for values equal or greater than 0.5 is a failure and therefore it prints 0 for that value.
Our ans is: 1 1 1 0. Which means that 3 times we have value less than 0.5 and 1 times we had values greater or equal to 0.5.


m. - tashuhka