Question: Write a function called event that simulates the scenario below. The function should have no inputs and a single output that must be either 0

 Write a function called event that simulates the scenario below. The

Write a function called event that simulates the scenario below. The function should have no inputs and a single output that must be either 0 or 1. A given bag of candy has 60 pieces of candy. Each piece of candy has an equal probability of being any one of four different flavors. Simulate a bag of candy and have your function return a 1 if there are 4 or fewer pieces of a given flavor. If there are 5 or more pieces of all four flavors, return a 0. Function C Reset MATLAB Documentation 1 function out=event Code to call your function C Reset 1 %This script calculates the approximate probability cnt=0; 3 for j=1:1000 4 cnt=cnt+event; 5 end 100*(cnt/1000)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!