generating 10 samples from a binomial using a fair dice.
Mostrar comentarios más antiguos
clc
clear all
format compact
rng(970,'v4')
U=[];
X=[];
R = rand(10,1) % generate a sample in Unif(0,1)
P = [1/6,2/6,3/6,4/6,5/6,1];
js = [1:6]; F = cumsum(P); disp(F)
if R < 1/6
x=1
X=[Xx]
U=[UR];
else if R >= 1/6 & R <2/6
x=2
X=[Xx]
U=[UR];
else if R >= 2/6 & R < 3/6
x=3
X=[Xx]
U=[UR];
else if R >= 3/6 & R < 4/6
x=4
X=[Xx]
U=[UR];
else if R >= 4/6 & R < 5/6
x = 5
X=[Xx]
U=[UR];
else if R >=5/6 & R < 1
x=6
X =[Xx]
U=[UR];
end
end
end
end
end
end
i wanted my outcome to come out in terms of 1,2,3,4,5,6 when my x are these values
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!