Bernouli Distribution
Essay Preview: Bernouli Distribution
Report this essay
MID-TERM ASSIGNMENTQuestion :If an experiment will either succeed (成功) or fail (失敗). The probability of success is 30%, therefore, that of failure is 70%. To record the result of experiment, let 1 represents the success, and 0 represents the failure. In fact, this is so-called Bernoulli distribution (伯努力分配). How to create a random scalar, who has 30% of probability to be 1, while 70% of probability to be 0? In practice, we can make a random uniform distribution scalar (denoted by y, 0Please make a random matrix (size=100×50) consisting of independent Bernoulli distribution (for any element of the matrix, it can be either 1 or 0, according to the probability of 30% and 70%, respectively)Answer :Method 1Method 2vs=rndu(100,50);result=zeros(100,50);for i(1,100,1); for j(1,50,1); if vs[i,j]>0.3; result[i,j]=0; else; result[i,j]=1; endif; endfor;endfor;result;vs=rndu(100,50);result=zeros(100,50);for i(1,100,1); for j(1,50,1); if vs[i,j]<0.3; result[i,j]=1; else; result[i,j]=0; endif; endfor;endfor;result;Explanation :Method 1vs=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]>0.3;//to make command for the content of random uniform that I made, if greater than 0.3 means fail represent by 0// result[i,j]=0;//the result of the command that was made. 0=fail// else;//for other result// result[i,j]=1;//other than the above command or less than 0.3 means success represent by 1// endif; //to close the command// endfor;//to close the command//endfor;//to close the command//result;//to pull out the result//[pic 1]Method 2vs=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]<0.3;//to make partition for the content of random uniform that I made, if less than 0.3 means success represent by 1// result[i,j]=1;//the result of the partition that was made. 1=success// else;//for other result// result[i,j]=0;//other than the above command or bigger than 0.3 means fail represent by 0// endif; //to close the command// endfor;//to close the command//
Essay About Result Of Experiment And Random Uniform Distribution
Essay, Pages 1 (284 words)
Latest Update: July 5, 2021
//= get_the_date(); ?>
Views: 31
//= gt_get_post_view(); ?>
Result Of Experiment And Random Uniform Distribution. (July 5, 2021). Retrieved from https://www.freeessays.education/result-of-experiment-and-random-uniform-distribution-essay/