(1)Using the Matlab code developed in Software Assignment #1: a. Convert the code that generates the random...

70.2K

Verified Solution

Question

Basic Math

(1)Using the Matlab code developed in Software Assignment#1:

a. Convert the code that generates the random number (H,T) withequal probabilities into a function called myBernolli(p, S) thattakes as an input the probability of success p and S is the outcomedefined as success (either T or H) and returns the outcome of thetrial (either T or H).

b. Test that your function is actually producing the successfuloutcome with probability p by running the function in a loop of1000 trials and counting how many times success is produced (itshould be close to p*1000).

c. Write a Matlab function called myBinomial(n,p) that takes asan input the total number of trials n, the probability of success pand the outcome defined as success S and uses myBernolli() toreturn as an output the number of successes x.

d. Write a Matlab function called myGeometric() that takes as aninput the probability of success p and the outcome defined assuccess S and uses myBernolli() to return as an output the numberof trials till first success x.

e. Verify that myBinomial() and myGeometric() generates valuesthat follow Binomial and Geometric Distributions by running each ofthem 5000 times in a loop and plotting a histogram of the randomvariable x generated from each.

Hints: Random numbers with probability p are generated in Matlabusing the command function rand(). Read the help on Matlab to knowhow to use the function by typing help rand in Matlab command line.Histogram plots [hist()] is a function in Matlab. Read its help toknow how to produce

Answer & Explanation Solved by verified expert
3.6 Ratings (472 Votes)
ans code to copy a bernoulis Bernoullis    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students