Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB PROGRAM PLEASE MATLAB PROGRAM PLEASE Assignment: I. Create a function called bern,m that returns the probability of & successes in N trials of an

MATLAB PROGRAM PLEASE
image text in transcribed
MATLAB PROGRAM PLEASE Assignment: I. Create a function called bern,m that returns the probability of & successes in N trials of an independent experiment with individual probability of p. Your function must accept three parameters: &, N and p. Your function must return the Bernoulli probability Your function should include error checking. Check the he lp information for the MATLAB functions error ander return. You should verify d at 20 and N>0 and &SN etc: when there is a problem, you should notify the user of the issue and return to the calling function without calculating anything. 2. Empirically test the validity of the Bernoulli equation using your dice rolling function from the pre-lab assignment. This part of the lab doesn't need to be described in your report-this is just to learn the approach. Create and edit a script 1ab02.to empirically lest the Bernoulli equation and compare it to the theoretically predicted re sult. Assuming we want to examine the probability that out of N dice rolls, × the dice value was in some certain range (e.g. the oulcome that the die face is even), ollow this strategy: Start by seeding your random number generator such that it generates a different andom stream each time it executes based on the current clock (see RandStream or use rng ( shuffle") or other methods). This should be done only ence in your code and towards the very beginning of your main script lab02.m. Loop to call your dice function to roll the dice N times while keeping count of the number of times the die value was in the specified range (for our example, count the number of times the dice value was 2,4 or 6). This is & for this trial . Assign Success to this trial ifk rolls were in the desired range and Failure to this trial if A rolls were not in the desired range Run L.trials of this experiment and count the number of successful trials. That is, repeat the experiment of olling the die N times itself L times (where Lis a large number; the larger the better-computers are pretty fast so don't be shy). Compute the empirical determined probability of achieving k successes in N trials by computing the ratio of the number of tests in which & successes were achieved to the total number of tests L Compare to the theoretical result by calling your bern function. Format output to the user to inform them of your empirically determined result as compared to your theoretically predicted result. Compute percent dif lerence. Configure your lab02 m script to compare the theoretical and empirical results for the lest cases enumerated below (assuming independent rolls of a fair die). Format your output to properly describe the experiment and the results: a. In 5 out of 10 die rolls, the face value is even b. In 9 rolls, the face numbers 3 and 5 never occur c In 30 rolls, there are at least 11 prime numbers (note: 1 is not prime) d. In 8 rolls, the die face is greater than 3 more often than not. 4 Compare your results. Do the empirical and theoretic al re sults agree? Why or why not S. Do the numbers you obtain make sense? For example, the probability of obtaining an even-valued die face is p-0.5, yet is the probability of obtaining exactly 5 even rolls in 10 tries equal to 0.57 Explain your findings

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

What is business strategy?

Answered: 1 week ago

Question

Define the goals of persuasive speaking

Answered: 1 week ago