The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
If you can solve all 4 questions, let me know then I pay you $40.
1. The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have the same birthday? It is possible to determine the answer to this question via simulation. Write a function called calcBirthdayProbability that takes as input n and calculates the probability that two or more of the n people will have the same birthday. To do this, the function should create an array of size n and generate n birthdays in the range 1 to 365 randomly. It should then check to see if any of the n birthdays are identical. The function should perform this experiment 106 times and calculate the fraction of time during which two or more people had the same birthday.
Â
Â
ENGR 121: Computation Lab IProgramming Assignment 2This assignment comprises of four problems. Submit functions for each of the problems byNovember 30, 2016, 11:59 pm. Detailed submission instructions are available towards the endof this document.You must work on this assignment on your own. Submitted solutions must be your original work.Solutions copied from other students or from online sources will result in a grade of zero for theentire assignment.1. (10 points) The sine function can be evaluated via the following infinite series:sin(x) =x-x33!+x55!-x77!+· · ·Write a functionapproxSinethat takes as input two parameters,xandthreshold, to performthe following task. Starting with the initial approximationsin(x) =x, add terms one at a time toimprove this estimate untilvvvvtrue value-approximationtrue valuevvvv<threshold.Assume that the true value of sine is the one returned by the built-insinfunction in MATLAB.Your function must return two output values: the approximate value ofsin(x)and the number ofterms that were needed to obtain this value subject to the desired error threshold. The following isan example of function behavior forx=π/5.>> x = pi/5;>> true_value = sin(x)real =0.5878>> threshold = 0.001;>> [approx terms] = approxSine(x, threshold)approx =0.5878terms =2>> threshold = 0.00001;>> [approx terms] = approxSine(x, threshold)approx =0.5878terms =3Note that thetermsvalue returned by the function only counts the number of terms added to thestarting approximation ofsin(x).1
Attachments:
-----------