Question: i need help explaining what i learned in this lab I learned to when you are working with two different libraries to specify them. For
i need help explaining what i learned in this lab I learned to when you are working with two different libraries to specify them. For the poisson lab specifying the poisson to find the theoretical mean. And for r1 we used the numpy lab.
import numpy as np # import the correct module and function from scipy . stats import poisson x = int(input()) lam = int(input() ) UT N np . random. seed ( seed=123) r1 = poisson. rvs(lam, size=8) # Generate 8 random numbers with a Poisson distribution with a mean of Lam r2 = poisson. rvs(lam, size=20) # Generate 20 random numbers with a Poisson distribution with a mean of Lam r3 = poisson. rvs(lam, size=100) # Generate 100 random numbers with a Poisson distribution with a mean of Lam cp = poisson. cdf(x, lam) # Calculate the cumulative probability of x or fewer successes for a Poisson distribution with a mean of Lam print(f' Cumulative probability is {cp:.6f}') mean_theor = poisson. mean(lam)# Calculate the theoretical mean of the Poisson distribution print("Theoretical mean is", mean_theor) mean_r1 = np. mean(r1) # Calculate the actual mean of r1 print (f'Mean of 1 is {mean_1:. 6f}' ) mean_r2 = np. mean(r2) # Calculate the actual mean of r2 print (f'Mean of r2 is {mean_r2: . 6f}' ) mean_r3 = np. mean(r3) # Calculate the actual mean of r3 print (f'Mean of r3 is {mean_r3:. 6f}' )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
