MIE360-Python代写
时间:2023-09-30
MIE 360: Systems Modeling and Simulation (Fall 2023)
Tutorial 2: CLT and Monte Carlo Simulation
1. An insurance company serves five large customers. The insurance claim placed by each cus-
tomer in a year is exponentially distributed with mean 200. Assume that the insurance claims
from different customers are independent from each other.
(a) Estimate the probability that the total insurance claim placed by all customers in a year
exceeds 900 by using the CLT.
(b) Use simulation to estimate this probability. First, find the required number of samples
to achieve ±0.01 accuracy with 95% confidence using the approach discussed in the
lecture. Then use the obtained number of samples to get the estimate. Implement
your solution using Python. You might find the list of Python functions at the end
of this document helpful. (Hint: In this question you may use the Python function
numpy.random.exponential(scale=α, size=n) to generate n random exponential numbers
with mean α. Later in the course you will learn how to transform uniform random
numbers into exponential ones.)
(c) Repeat parts a) and b) for 30 customers’ total claims exceeding 5,400.
2. The lifetime of a special type of battery has mean 40 hours and standard deviation 20 hours
(the unknown distribution does not take negative values). A battery is used until it depletes
at which point it is replaced by a new one. Use the central limit theorem to estimate the
number of required batteries, the lifetimes of which are independent, so that the probability
that we obtain a total of 1,100 hours of use is more than 88.5%.
3. Assume that you rolled a die for 10,000 times and the outcomes that you obtained are given
by the data in the attached spreadsheet (“Tutorial 2.xlsx”). You suspect if the die is fair or
not.
Note: You can download the attached “Tutorial 2.ipynb” Jupyter (IPython) Notebook which
contains the code for reading the data and storing it as a numeric array. You need to put the
file (Tutorial 2.xlsx) and Tutorial 2.ipynb in the same folder before executing the code.
(a) Compute a 95% CI for the mean roll of the given die based on the given data, and
compare your CI to the value you should obtain if the die is actually fair. Does the die
look fair?
(b) Compute a 95% CI for the probability that a roll of the given die yields the value 1, and
compare your CI to the value you should obtain if the die is actually fair. Does the die
look fair?
(c) Explain the differences, if any, in your conclusion between parts a and b.
1
Useful Python Functions
Numpy, Scipy and Pandas packages are needed to use the following functions.
pandas.read excel(file.xlsx) Reads data from an Excel file.
pandas.read csv(file.csv) Reads data from a CSV file.
numpy.random.rand() Generates a random variable that is uniformly distributed between 0 and
1.
numpy.random.uniform(a, b) Generates a random variable that is uniformly distributed be-
tween a and b.
numpy.random.normal(µ, σ) Generates a normally distributed random variable with mean µ
and standard deviation σ.
numpy.random.exponential(α, β) Generates β number of exponentially distributed random
variable with mean α. This can be used to generate interarrival times in a Poisson process.
numpy.min(array) Shows the minimum value in a given array.
numpy.max(array) Shows the maximum value in a given array.
numpy.mean(array) Calculates the average value of a given array.
numpy.std(array) Calculates the sample standard deviation of a given array.
numpy.floor(num) Rounds the number num down to the nearest integer.
numpy.ceil(num) Rounds the number num up to the nearest integer.
numpy.sqrt(num) Takes the square root of the given number num.
numpy.random.choice(array, size=num) Randomly selects num items from the given array.
scipy.stats.norm.ppf(prob) Inverse of cdf of standard normal distribution.


essay、essay代写