89 minute read
The goal of input analysis is to ensure that the random variables we use in our simulations adequately approximate the real-world phenomena we are modeling. We might use random variables to model interarrival times, service times, breakdown times, or maintenance times, among other things. These variables don't come out of thin air; we have to specify them appropriately.
If we specify our random variables improperly, we can end up with a GIGO simulation: garbage-in-garbage-out. This situation can ruin the entire model and invalidate any results we might obtain.
Let's consider a single-server queueing system with constant service times of ten minutes. Let's incorrectly assume that we have constant interarrival times of twelve minutes. We should expect to never have a line under this assumption because the service times are always shorter than the interarrival times.
However, suppose that, in reality, we have Exp(12) interarrival times. In this case, the simulation never sees the line that actually occurs. In fact, the line might get quite long, and the simulation has no way of surfacing that fact.
Here's the high-level game plan for performing input analysis. First, we'll collect some data for analysis for any random variable of interest. Next, we'll determine, or at least estimate, the underlying distribution along with associated parameters: for example, Nor(30,8). We will then conduct a formal statistical test to see if the distribution we chose is "approximately" correct. If we fail the test, then our guess is wrong, and we have to go back to the drawing board.
In this lesson, we will look at some high-level methods for examining data and guessing the underlying distribution.
We can always present data in the form of a histogram. Suppose we collect one hundred observations, and we plot the following histogram. We can't really determine the underlying distribution because we don't have enough cells.
Suppose we plot the following histogram. The resolution on this plot is too granular. We can potentially see the underlying distribution, but we risk missing the forest for the trees.
If we take the following histogram, we get a much clearer picture of the underlying distribution.
It turns out that, if we take enough observations, the histogram will eventually converge to the true pdf/pmf of the random variable we are trying to model, according to the Glivenko–Cantelli theorem.
If we turn the histogram on its side and add some numerical information, we get a stem-and-leaf diagram, where each stem represents the common root shared among a collection of observations, and each leaf represents the observation itself.
When looking at empirical data, what questions might we ask to arrive at the underlying distribution? For example, can we at least tell if the observations are discrete or continuous?
We might want to ask whether the distribution is univariate or multivariate. We might be interested in someone's weight, but perhaps we need to generate height and weight observations simultaneously.
Additionally, we might need to check how much data we have available. Certain distributions lend themselves more easily to smaller samples of data.
Furthermore, we might need to communicate with experts regarding the nature of the data. For example, we might want to know if the arrival rate changes at our facility as the day progresses. While we might observe the rate directly, we might want to ask the floor supervisor what to expect beforehand.
Finally, what happens when we don't have much or any data? What if the system we want to model doesn't exist yet? How might we guess a good distribution?
Let's suppose we know that we have a discrete distribution. For example, we might realize that we only see a finite number of observations during our data collection process. How do we determine which discrete distribution to use?
If we want to model success and failures, we might use a Bernoulli random variable and estimate . If we want to look at the number of successes in trials, we need to consider using a binomial random variable.
Perhaps we want to understand how many trials we need until we get our first success. In that case, we need to look at a geometric random variable. Alternatively, if we want to know how many trials we need until the th success, we need a negative binomial random variable.
We can use the Poisson() distribution to count the number of arrivals over time, assuming that the arrival process satisfies certain elementary assumptions.
If we honestly don't have a good model for the discrete data, perhaps we can use an empirical or sample distribution.
What if the distribution is continuous?
We might consider the uniform distribution if all we know about the data is the minimum and maximum possible values. If we know the most likely value as well, we might use the triangular distribution.
If we are looking at interarrival times from a Poisson process, then we know we should be looking at the Exp() distribution. If the process is nonhomogeneous, we might have to do more work, but the exponential distribution is a good starting point.
We might consider the normal distribution if we are looking at heights, weights, or IQs. Furthermore, if we are looking at sample means or sums, the normal distribution is a good choice because of the central limit theorem.
We can use the Beta distribution, which generalizes the uniform distribution, to specify bounded data. We might use the gamma, Weibull, Gumbel, or lognormal distribution if we are dealing with reliability data.
When in doubt, we can use the empirical distribution, which is based solely on the sample.
As we said, we will choose a "reasonable" distribution, and then we'll perform a hypothesis test to make sure that our choice is not too ridiculous.
For example, suppose we hypothesize that some data is normal. This data should fall approximately on a straight line when we graph it on a normal probability plot, and it should look normal when we graph it on a standard plot. At the very least, it should also pass a goodness-of-fit test for normality, of which there are several.
It's not enough to decide that some sequence of observations is normal; we still have to estimate and . In the next few lessons, we will look at point estimation, which lets us understand how to estimate these unknown parameters. We'll cover the concept of unbiased estimation first.
A statistic is a function of the observations that is not explicitly dependent on any unknown parameters. For example, the sample mean, , and the sample variance, , are two statistics:
Statistics are random variables. In other words, if we take two different samples, we should expect to see two different values for a given statistic.
We usually use statistics to estimate some unknown parameter from the underlying probability distribution of the 's. For instance, we use the sample mean, , to estimate the true mean, , of the underlying distribution, which we won't normally know. If is the true mean, then we can take a bunch of samples and use to estimate . We know, via the law of large numbers that, as , .
Let's suppose that we have a collection of iid random variables, . Let be a function that we can compute based only on the observations. Therefore, is a statistic. If we use to estimate some unknown parameter , then is known as a point estimator for .
For example, is usually a point estimator for the true mean, , and is often a point estimator for the true variance, .
should have specific properties:
We say that is unbiased for if . For example, suppose that random variables, are iid anything with mean . Then:
Since , is always unbiased for . That's why we call it the sample mean.
Similarly, suppose we have random variables, which are iid . Then, is unbiased for . Even though is unknown, we know that is a good estimator for .
Be careful, though. Just because is unbiased for does not mean that is unbiased for : . In fact, is biased for in this exponential case.
Here's another example. Suppose that random variables, are iid anything with mean and variance . Then:
Since , is always unbiased for . That's why we called it the sample variance.
For example, suppose random variables are iid . Then is unbiased for .
Let's give a proof for the unbiasedness of as an estimate for . First, let's convert into a better form:
Let's rearrange the middle sum:
Remember that represents the average of all the 's: . Thus, if we just sum the 's and don't divide by , we have a quantity equal to :
Now, back to action:
Let's take the expected value:
Note that is the same for all , so the sum is just :
We know that , so . Therefore:
Remember that , so:
Furthermore, remember that . Therefore:
Unfortunately, while is unbiased for the variance , is biased for the standard deviation .
In this lesson, we'll look at mean squared error, a performance measure that evaluates an estimator by combining its bias and variance.
We want to choose an estimator with the following properties:
Furthermore, we want the estimator to have both of these properties simultaneously. If the estimator has low bias but high variance, then its estimates are meaninglessly noisy. Its average estimate is correct, but any individual estimate may be way off the mark. On the other hand, an estimator with low variance but high bias is very confident about the wrong answer.
Suppose that we have random variables, . We know that our observations have a lower bound of , but we don't know the value of the upper bound, . As is often the case, we sample many observations from the distribution and use that sample to estimate the unknown parameter.
Consider two estimators for :
Let's look at the first estimator. We know that , by definition. Similarly, we know that , since is always unbiased for the mean. Recall how we compute the expected value for a uniform random variable:
As we can see, is unbiased for .
It's also the case that is unbiased, but it takes more work to demonstrate. As a first step, take the cdf of the maximum of the 's, . Here's what looks like:
If , and is the maximum, then is the probability that all the 's are less than . Since the 's are independent, we can take the product of the individual probabilities:
Now, we know, by definition, that the cdf is the integral of the pdf. Remember that the pdf for a uniform distribution, , is:
Let's rewrite :
Again, we know that the pdf is the derivative of the cdf, so:
With the pdf in hand, we can get the expected value of :
Note that , so is not an unbiased estimator for . However, remember how we defined :
Therefore, is unbiased for .
Both indicators are unbiased, so which is better? Let's compare variances now. After similar algebra, we see:
Since the variance of involves dividing by , while the variance of only divides by , has a much lower variance than and is, therefore, the better indicator.
The bias of an estimator, , is the difference between the estimator's expected value and the value of the parameter its trying to estimate: . When , then the bias is and the estimator is unbiased.
The mean squared error of an estimator, , the expected value of the squared deviation of the estimator from the parameter: .
Remember the equation for variance:
Using this equation, we can rewrite :
Usually, we use mean squared error to evaluate estimators. As a result, when selecting between multiple estimators, we might not choose the unbiased estimator, so long as that estimator's MSE is the lowest among the options.
The relative efficiency of one estimator, , to another, , is the ratio of the mean squared errors: . If the relative efficiency is less than one, we want ; otherwise, we want .
Let's compute the relative efficiency of the two estimators we used in the previous example:
Remember that both estimators are unbiased, so the bias is zero by definition. As a result, the mean squared errors of the two estimators is determined solely by the variance:
Let's calculate the relative efficiency:
The relative efficiency is greater than one for all , so is the better estimator just about all the time.
In this lesson, we are going to talk about maximum likelihood estimation, which is perhaps the most important point estimation method. It's a very flexible technique that many software packages use to help estimate parameters from various distributions.
Consider an iid random sample, , where each has pdf/pmf . Additionally, suppose that is some unknown parameter from that we would like to estimate. We can define a likelihood function, as:
The maximum likelihood estimator (MLE) of is the value of that maximizes . The MLE is a function of the 's and is itself a random variable.
Consider a random sample, . Find the MLE for . Note that, in this case, , is taking the place of the abstract parameter, . Now:
We know that exponential random variables have the following pdf:
Let's expand the product:
We can pull out a term:
Remember what happens to exponents when we multiply bases:
Let's apply this to our product (and we can swap in notation to make things easier to read):
Now, we need to maximize with respect to . We could take the derivative of , but we can use a trick! Since the natural log function is one-to-one, the that maximizes also maximizes . Let's take the natural log of :
Let's remember three different rules here:
Now, let's take the derivative:
Finally, we set the derivative equal to and solve for :
Thus, the maximum likelihood estimator for is , which makes a lot of sense. The mean of the exponential distribution is , and we usually estimate that mean by . Since is a good estimator for , it stands to reason that a good estimator for is .
Conventionally, we put a "hat" over the that maximizes the likelihood function to indicate that it is the MLE. Such notation looks like this: .
Note that we went from "little x's", , to "big x", , in the equation. We do this to indicate that is a random variable.
Just to be careful, we probably should have performed a second-derivative test on the function, , to ensure that we found a maximum likelihood estimator and not a minimum likelihood estimator.
Let's look at a discrete example. Suppose we have . Let's find the MLE for . We might remember that the expected value of Bern() random variable is , so we shouldn't be surprised if is our MLE.
Let's remember the values that can take:
Therefore, we can write the pmf for a Bern() random variable as follows:
Now, let's calculate . First:
Remember that . So:
Let's take the natural log of both sides, remembering that :
Let's take the derivative, remembering that the derivative of equals :
Now we can set the derivative equal to zero, and solve for :
In this lesson, we'll look at some additional MLE examples. MLEs will become very important when we eventually carry out goodness-of-fit tests.
Suppose we have . Let's find the simultaneous MLE's for and :
Let's take the natural log:
Let's take the first derivative with respect to , to find the MLE, , for . Remember that the derivative of terms that don't contain are zero:
What's the derivative of with respect to ? Naturally, it's . Therefore:
We can set the expression on the right equal to zero and solve for :
If we solve for , we see that , which we expect. In other words, the MLE for the true mean, , is the sample mean, .
Now, let's take the derivative of with respect to . Consider:
We can set the expression on the right equal to zero and solve for :
Notice how close is to the unbiased sample variance:
Because is unbiased, we have to expect that is slightly biased. However, has slightly less variance than , making it the MLE. Regardless, the two quantities converge as grows.
Let's look at the Gamma distribution, parameterized by and . The pdf for this distribution is shown below. Recall that is the gamma function.
Suppose we have . Let's find the MLE's for and :
Let's take the natural logarithm of both sides, remembering that :
Let's get the MLE of first by taking the derivative with respect to . Notice that the middle two terms disappear:
Let's set the expression on the right equal to zero and solve for :
It turns out the mean of the Gamma distribution is . If we pretend that then we can see how, with a simple rearrangement, that .
Now let's find the MLE of . First, we take the derivative with respect to :
We can define the digamma function, , to help us with the term involving the gamma function and it's derivative:
At this point, we can substitute in , and then use a computer to solve the following equation, either by bisection, Newton's method, or some other method:
The challenging part of evaluating the digamma function is computing the derivative of the gamma function. We can use the definition of the derivative here to help us, choosing our favorite small and then evaluating:
Suppose we have . Let's find the MLE for .
Remember that the pdf . We can take the likelihood function as the product of the 's:
In order to have , we must have . In other words, must be at least as large as the largest observation we've seen yet: .
Subject to this constraint, is not maximized at . Instead is maximized at the smallest possible value, namely .
This result makes sense in light of the similar (unbiased) estimator that we saw previously.
In this lesson, we will expand the vocabulary of maximum likelihood estimators by looking at the invariance property of MLEs. In a nutshell, if we have the MLE for some parameter, then we can use the invariance property to determine the MLE for any reasonable function of that parameter.
If is the MLE of some parameter, , and is a 1:1 function, then is the MLE of .
Remember that this invariance property does not hold for unbiasedness. For instance, we said previously that the sample variance is an unbiased estimator for the true variance because . However, , so we cannot use the sample standard deviation as an unbiased estimator for the true standard deviation.
Suppose we have a random sample, . We might remember that the MLE of is . If we consider the 1:1 function , then the invariance property says that the MLE of is .
Suppose we have a random sample, . We saw previously that the MLE for is:
We just said that we couldn't take the square root of to estimate in an unbiased way. However, we can use the square root of to get the MLE for .
If we consider the 1:1 function , then the invariance property says that the MLE of is:
Suppose we have a random sample, . The survival function, , is:
We saw previously the the MLE for is .Therefore, using the invariance property, we can see that the MLE for is :
The MLE for the survival function is used all the time in actuarial sciences to determine - somewhat gruesomely, perhaps - the probability that people will live past a certain age.
In this lesson, we'll finish off our discussion on estimators by talking about the Method of Moments.
The th moment of a random variable is:
Suppose we have a sequence of random variables, , which are iid from pmf/pdf . The method of moments (MOM) estimator for , , is:
Note that is equal to the sample average of the 's. Indeed, the MOM estimator for , is the sample mean, :
Similarly, we can find the MOM estimator for :
We can combine the MOM estimators for to produce an expression for the variance of :
Of course, it's perfectly okay to use to estimate the variance, and the two quantities converge as grows.
Suppose that . We know that, for the Poisson distribution, , so a MOM estimator for is .
We might remember that the variance of the Poisson distribution is also , so another MOM estimator for is: