Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

How to perform Matlab for the biased coin toss

Apr 21, 2018 2:22PM PDT

Let the bias be the probability of turning up a head and denoted by the parameter q.

If we use a coin with the bias specified by q to conduct a coin flipping process d times, the outcome will be a sequence of heads and tails.

Then the probability - where nH is the number of heads turned up during d trials.

Now using such a simulated coin with q = ½ to conduct the experiments based on a sequence of outcomes generated by the random generator from computer.

For example, if the number generated by the random generator is less than 1/2, it assigned to be 0; otherwise, it will be assigned 1.

I would like to perform the Matlab programming with certain parameters for the Pattern Recognition (such as Binomial Distribution) as below -

(1) d = 100 and n =100 using a simulated coin with q = ¼ and ½.

(2) d = 10 and n =1000 using a simulated coin with q = ¼ and ½.

(3) d = 100 and n = 1000 using a simulated coin with q = ¼ and ½.

Kindly please provide your opinion and suggestion thus I will be able to improve my computing skills.

(The result of the execution from program will be drawn into histogram on the PowerPoint)

Discussion is locked

- Collapse -
Answer
I worry you skipped research on this.
Apr 21, 2018 3:36PM PDT
- Collapse -
I get some errors for my coding
Apr 23, 2018 4:27PM PDT
Matlab Programming Method - I get some errors for my coding sample as below


(1)

x = rand(0,1);
if(x<0.25),
toss = 0; %Head
else
toss = 1; %Tail
end
n = 100;
d = 100;
hist(y,0:n)

x = rand(0,1);
if(x<0.5),
toss = 0; %Head
else
toss = 1; %Tail
end
n = 100;
d = 100;
hist(y,0:n)
- Collapse -
For that, find coding forums.
Apr 25, 2018 9:03AM PDT