What would be the simulation for the following statement?: A fair coin is tossed until the first head occurs. Do this Z = 10 times and plot the relative frequencies of this occurring at the ith toss, for suitable values of i.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Bill King
el 1 de Abr. de 2014
Respondida: ragesh r menon
el 1 de Abr. de 2014
A fair coin is tossed until the first head occurs. Do this Z = 10 times and plot the relative frequencies of this occurring at the ith toss, for suitable values of i.
0 comentarios
Respuesta aceptada
ragesh r menon
el 1 de Abr. de 2014
clear all
clc
close all
z=10;%number of times you want to repeat the experiment
s=zeros(0,z);
for j=1:z
coin=[];
i=1;
coin(i)=round(rand(1,1));
while(coin(i)==0)
i=i+1;
coin(i)=round(rand(1,1));
end
coin
s(j)=length(coin);
end
stem(s)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MuPAD en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!