Bernouli Distribution
Autor: Jannisthomas • June 10, 2018 • 646 Words (3 Pages) • 607 Views
...
endfor;//to close the command//
result;//to command pull out the result//
[pic 2]
(2) Consider a little bit more complicated case. There’s an experiment with three-state results. Let the following numbers, says, 1,-1,0, to represent the results of success, failure, and tie. However, it is not a fair game, since the probability of the result of success, failure, and tie are 20%, 50%, and 30%, respectively. Please make a random matrix (size=100×50) consisting of results of the independent trials stated above (for any element of the matrix, it can be either 1, -1 or 0, according to the probability of 20%, 50% and 30%, respectively)
Reminder: In question 2, you should provide not only the results, but also the Gauss programs (or commands). You can check whether your Gauss procedure is workable or not. If not, try to revise it.
Answer :
vs=rndu(100,50); //I want to create random uniform consist of 100 rows and 50 columns//
result=zeros(100,50); //I want to fill the random uniform with zeros of 100 rows and 50 columns//
for i(1,100,1); //i represent the row. I want the rows start with 1 end in 100 with 1 interval//
for j(1,50,1); //j represent the column. I want the column start with 1 end in 50 with 1 interval//
if vs[i,j]
result[i,j]=1;//to call the result of the above command, less than 0,2 means success represent by 1//
elseif vs[i,j]>0.5;//to make other command for the content of random uniform that I made, if greater than 0.5 means fail represent by -1//
result[i,j]=-1;//to call the result of the above command, more than 0,5 means fail represent by -1//
else;//other than the two commands above means tie represent by 0//
result[i,j]=0;//to call the result of other than the two commands above, greater than 0,2 but less than 0,5 means tie represent by 0//
endif;//to close the command//
endfor;//to close the command//
endfor;//to close the command//
result;//to close the command//
[pic 3]
...