Question: The question need to use Python. Please answer within 6hrs and I will give you thumbs up. Q3. Suppose that an event repeatedly occurs over
Q3. Suppose that an event repeatedly occurs over time at a constant rate but at random (Poisson process). For example, let's observe the arrival of buses at a bus stop. On average we see a bus every 10 minutes. However, the time interval between the arrivals of two buses is exactly 10 minutes. We may see the buses, for example, at 0 min, 13.1 min, 19.7 min, 33.3 min, 40.2 min, ... We divide a time period of concern into n pieces. In each piece of time interval, the probability for occurrence of an event is p [0, 1]. Then, the probability that this event occurs k times in the whole time period is n! Pr(k, n, p) p(1-p-k k!(n-k)! This is called binomial distribution. Do the following operations by SymPy. 1. Define the symbols n and k standing for two nonnegative integers. Define the symbol p standing for a nonnegative real number. 2. Define the expression for Pr(k,n, p) and print out this expression by pprint(). 3. Substitute n = 20 and p = 0.5 into the expression of Pr(k,n, p). Then, the new expression is only a function of k, i.e., Pr(k) 4. Convert the SymPy expression Pr(k) to a python function called binomial_prob_k_func() by sympy.lambdify . Note that the expression Pr(k) may contain the operation sympy.factorial() which is not supported by NumPy but is supported by Scipy. So, we cannot use sympy.lambdify( ..., "numpy"); instead, we must use sympy.lambdify( ..., "scipy"). 5. Try three sets of parameters: n = 20 and p = 0.4, n = 20 and p = 0.7. n = 40 and p = 0.5 Similar to Question 3, for each set of parameters, substitute n and p to the expression of Pr(k,n, p). Then, similar to Question 4, for each set of parameters, define the python function binomial_prob_k_func(). Finally, for each set of parameters, plot this python function, i.e., Pr(k). (25 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
