generating 10 samples from a binomial using a fair dice.
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!