the question say Given a dice with six numbers 1 2 3 4 5 6
the question say :
Given a dice with six numbers ({1, 2, 3, 4, 5, 6}), each number comes with the same probability when you roll it. Here is the game. Suppose you have such TWO dices and you simultaneously roll both of them to get the product of the two output numbers. When the product is 1 or 36, we say that you get the magic numbers and you will be rewarded. However, each play will cost you a certain amount of money and you can only afford to play 100 times. Let the random variable X denote the total number of times you will hit those magic numbers and be rewarded. Image you are repeating this game a 1000 times, and counting how many times have you won during each game. You have to show the distribution of getting the magic numbers by plotting the histogram.
that\'s the code i have so far !
n=1000 ;
x = randi(6,n,1);
y = randi(6,n,1);
distr = zeros (6,1) ;
count1= 0 ;
for k = 1 : n
ProductOf = x(k)*y(k);
if (ProductOf== 1 || ProductOf == 36 )
count1 = count1 + 1 ;
end
end
Bins = (2:6 * 2);
histogram(count1, Bins);
hold on
Solution
X denote total no. of times magic number is obtained out of 100 trials where each trial consists of noting the product of the scores on two unbiased dice.
Let U,V ~ DU {1,2,3,4,5,6} independently.
Then X= No. of times UV=1 or 36
Using the following codes in R
x=vector()
for(i in 1:1000)
{
u=sample(1:6,100,T)
v=sample(1:6,100,T)
uv=u*v
x[i]=length(uv[uv==36])+length(uv[uv==1])
}
hist(x)
we get the histogram as
The google drive link of the histogram is
https://drive.google.com/file/d/0B3CrWc4Iva8laVVUbml0Z3FFems/view?usp=sharing
From the histogram and from the definition of X we find that X follows binomial distribution with probability of success <0.5 .
(It can be shown that theoretically X~ Bin(100,1/7). )

