Lecture 26-Valid Model for Input Data

IIT Kanpur July 201
20 followers
Dec 2, 2023
Simulation of Business System, Valid Model for Input Data, Identifying the Distribution, Parameters Estimation, Suggested Estimators, Sample Mean, Sample Variance, Poisson Distribution Estimator, Exponential Distribution Estimator, Uniform Distribution Estimator, Normal Distribution Estimator, Gamma Distribution Estimator, Weibull Distribution Estimator, PDF, CDF, Kolmogorov Smirnov test.
Okay, students, good evening, once again welcome to the conclusive lecture of simulation of
business systems course and today we are going to look into how to create the, how to deal
with the input data for the models and how to use different parameters for the various
input models and also about a quick recap of what we did in the course and stuff and
other aspects to this so that we have a reasonably good idea of how the course is and what is
the purpose of taking this course and how can you take this course, the learnings that
you had in this course forward.
So without wasting much time, we will actually look into today's presentation and today's
data is about the valid model for input data, how do we create a valid models for it and
today's learning agenda is the four parts, how do you identify a distribution, just look
at an illustrative example, okay, because again people had issues and confusions and
doubts about histograms and probabilities, so we will take another quick example, then
we talk about parameter estimation and suggested estimators and this is kind of the lecture
15 of the course.
So the first question is identifying the distribution, okay, we already talked about this how do
we identify the distribution and the first and foremost, okay, most commonly used tool
in simulation is histogram, okay, you can using histograms, one can infer a non-PDF
or CDF, example, okay, exponential distribution, normal distribution and uniform distribution
are frequently encountered in system behaviours and can be easily identified, okay, so for
an example, if I say that if you look into this, let us say here is x and you have values
1, 2, 3, 4, 5 and 6 and this is let us talk about rolling a fair die, okay and you have
let us say here is the 1 by 6 as the probability and all the way to 0 to called as 1, so then
in this case, okay let us not do 1 by 6 here, we do 1 by 6 somewhere here, so for each case
you will have a distribution something like this, okay, you have all the cases, the probability
will be exactly the same.
So then we can easily infer that for this particular case, you can say that the distribution
from here, we can identify something like this, you have a distribution like this, 0
to a particular value and you can say that and here is the P of x, so this is a well
approximated uniform distribution, uniform 0, a distribution, let us say think about
another scenario where you have a distribution like this, here is your let us say here is
a probability and here is your 1, 2, 3, 4, 5, 6, 7, all the way like this and your histograms
looks something like this, let us say you see a scenario like this, then you can very
well from here, you can say that here is your x and here is your y and we can say that distribution
like this, so this can be approximated to exponential.
Another example you can think about it is we discussed this in the class earlier, if
you roll 2 fair dice, another process is like roll 2 fair dice and some face values, so
then you will have 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 like this and you have different
probabilities here like this okay and you will get a probability distribution something
like this, 4, 5, 6, a distribution like this where you can say that an approximated version
of this can be easily said like a bell shaped curve okay, where you can say that x and y
can say that okay, this approximated to normal, so these kind of things you can identify using
the histogram, you can identify appropriate distribution, so these 3 normal, uniform,
this is uniform, this is exponential okay and here is normal, these distributions are
quite easy okay, to do or develop the identify through the histogram.
Also for normal okay, for normal NPP is a good tool for small samples, so NPP stands
for normal probability plot okay, so think about this NPP is normal probability plot
okay, for small sample size less than 20, 50 or so, you can easily use NPP as a good
tool instead of the histogram also.
So, let me show you an example, an example problem, this will probably help you to understand
some of the stuff quickly, the number of vehicles arriving in at an intersection in
a 5 minute time period between 7 AM and 7 or 5 AM was monitored for 5 work days over
a 20 week period, so for 5 work days, so Monday, so this is Monday, Tuesday, Wednesday, Thursday,
Friday, 5 work days for 20 weeks, you stand at an intersection and 7 AM to 7 or 5, the
5 minutes in the morning and you observe the number of vehicles arriving at that intersection.
The resulting data is tabulated, it is given in a table below, the first entry in the table
indicates that there were 12 5 minute periods during which 0 vehicles arrived, so this 12,
this number 12 means of the this total, this numbers will total to this frequencies will
total 24 and this will total to 76, so the grand total is 24 plus 76 equal to 100, okay.
So, these 100 vehicle, the frequencies that you observed of the 12 frequencies that you
saw, 0 vehicles arrived, the 10 that you see here means, 1 vehicle arrived at an intersection,
19 times you saw 2 vehicles arriving at the intersection, this means 3 times you saw 9
vehicles arriving in the intersection and so on, okay.
So, if that is the case, then one way to think about it is since the number of vehicles is
a discrete variable, discrete means they are countable, okay, separated out, not continuous
and since there is ample data, the histogram can have a cell for each possible value in
the data range.
So, what we are telling is that number of vehicles are discrete, we are countably discrete
and since there is ample data, okay, then the histogram can have a cell for each possible
value in the data range, what are the values in the data range?
The values in the data ranges are this, these are the values in the data range, so if we
do that, so let us see, let us draw the histogram, if we draw the histogram, so then we can do
it this way, here is let us take it as fi, the frequency, x, the number of vehicles,
you have 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, okay, these are the numbers that we got
up to 11 and there are values here 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 like
this, okay.
And we saw that for 0, the number of values, so now we are going to plot this frequency,
so these are your fi frequencies, okay, so in this case, 0, it was 12, so we instead
of the histogram, we will plot a small histogram, I was trying to avoid drawing more lines,
this will be 12, then 1 was the previous data was 10, okay, so this will be 10 somewhere
here, then 2 was 19, the next one is 17, so 19 is somewhere here, right, 19, then
one after that it is 17, so somewhere between 16 and this one, then 4 is 10, so I will get
to 10 here, 4 is 10, 5 is 8, 6 is 7, 5 is 8, 6 is 7, so slightly less than that.
Then 7 is 5, 8 is 5, so we go to 5, 7 is 5, 8 is also 5, then 9 is 3, 10 is 3, 11 is 1,
so 9 is 3, 10 is 3, 11 is 1, so we draw a curve like this, what can you say, okay, can
you well, this is not a obviously a normal distribution, okay, so you can obviously say
not a normal distribution, okay because normal distribution ideally would be something like
this, right, you would have like a symmetric curve but you can think about a curve something
like this, maybe this approximates, maybe approximate, okay, a curve like this, maybe
people are looking at something like this, a curve like this, possible, it is possible,
okay.
So, here if you look at the number of arrivals in 5 minute period is the x axis and the frequencies
or you can do the relative frequency also you get the same graph, okay, same pattern
will be obtained in relative frequency, okay, one way to do this is you calculate the relative
frequency and calculate the CDF and then do the uniform 01 or otherwise you try to create
this.
Why do we try to create this?
Because if you go with, if the CDF model is followed then the system will never, not the
system, the model will never be better than the system, this was the problem we studied
this earlier, okay, if we use the CDF format, okay, if we convert this into frequencies
and the CDF then the model will be never better than the system, so hence we look to see whether
a probability distribution will fit, so our question is we are trying to see whether a
probability distribution will fit to the data, so that why, so we can do better, we might
be able to do better than the actual data.
So, that is the reason why we try to look into patterns and try to generate this kind
of probability distributions, so if you do not want to do this, let us say not to do
this and you say want to do this, then what do you need, okay, if probability distributions
are to be used, you need to estimate its parameters, so the difference in the previous case is
here you do not need any parameters, in this case you do not need any parameters, whereas
in this particular case parameters are required, you need to estimate your parameters.
So, parameter estimation, how do you estimate the parameters, okay, so the basic thing is
first thing is sample mean x bar is given by x bar is equal to sigma i equal to 1 to
n xi divided by n, okay, so that means sum all the x values, then individual observations
and then divide by the number of observations, you will get the x bar.
Similarly, sample variance, okay, s square is given by s square is equal to sigma i equal
to 1 to n xi square minus, okay, sorry, the bracket is not here, xi square minus nx bar
square divided by n minus 1, that is one option you can do, okay, so what you are trying to
do is here is that you are basically trying to estimate, so here, yeah, so you are looking
at the variance here in this case, okay and then go from there.
So, the idea here is that you can calculate this sample, the mean and the variance out
of this particular case but if you are using discrete data or data that is grouped into
classes in a frequency distribution, then the previous equations, let us call this as
equation 1 and equation 2, okay, then the previous equations 1 and 2 can be modified
to provide for much greater computational efficiency, so if you are using the discrete
data or you have data that is grouped into classes in a frequency distribution, then
the equation 1 and 2 can be modified for greater computational efficiency, so what
are those?
So, x bar will be given by sigma j equal to 1 to k fj times xj divided by n, so what you
are doing is individual frequencies multiplied by the value, individual xj's and you multiply
that and divide by n, you will get the x bar, okay.
This can also be said as okay, sigma j equal to 1 to n, you can say think about this whole
thing as you know, fj over n times xj, okay, so in this case what you are doing is this
is your relative frequency, this way also you can calculate, okay, you might see this
is equal to saying sigma all x p of x times x, okay, so you can see these are the estimates
of probability in this one particular case, okay.
Similarly, s square you can estimate it as in a particular fashion, you can estimate
it as sigma j is equal to 1 to k fj times xj square – n x bar square, right divided
by n – 1, so this is once you calculate x bar, then from there you can calculate the
variance, can be calculated using this equation, this is your fj is the frequency, this is
your frequency, okay, xj is individual observations.
You use n – 1, this is the degrees of freedom, this n – 1 is also exactly the same, the
degrees of freedom, right, so I hope you guys understand that, so this way if you know the
mean and the standard deviation, then quite a lot of distributions can be dealt with,
so the suggested estimates for various distributions are in this are given, okay, so I will give
you some examples of this, some of the commonly used distribution, so if you use Poisson distribution,
okay, this is for the number of arrivals, parameter required is alpha, okay or some
people call it as lambda also, sometimes lambda, the rule is use alpha equal to x bar, you
are using the mean for the alpha can be estimated as or alpha bar can be used as your x bar,
so that is one case.
Exponential distribution, parameter required is lambda, so use lambda bar is equal to 1
over x bar, so because Poisson and exponential are related to each other, you can think about
lambda as 1 over alpha or 1 over mu, you can think about it either way, so lambda bar
average can be used as 1 over x bar, so take the reciprocal of the mean, then another distribution
you can think about it is uniform, uniform distribution, parameter required is B, upper
limit, lower limit is taken as 0, so you are talking about uniform 0 B, that is the case
you can use B bar is equal to n plus 1 divided by n, let us put it this way, n plus 1 divided
by n times max value of x, so for B bar you use n plus 1, the number of observations n
plus 1 divided by n multiplied by the max value of x will give you the B bar, the upper
limit okay and this will be an unbiased estimator, this will be an unbiased one, that is one
thing to use the uniform.
Now for normal, normal parameters required are mu and sigma okay, use mu equal to mu
bar equal to x bar and sigma bar equal to s square root, both of these can be or sigma
bar square is equal to s square, either one of them we can use okay, so this will give
you the unbiased estimator for, this is also unbiased okay, so we can see that for Poisson
distribution, this is the number of arrivals usually, for to do that you require parameter
alpha and use x bar and this is just an estimator parameter, the exponential distribution is
usually time between arrivals okay and for that you use lambda bar is 1 over x bar.
Then uniform is typically a thing for all values equally likely and for this case you
use a 0 B, the minimum value is 0, maximum value is n plus 1 divided by n multiplied
by max value of x, maximum value of observation right.
Normal this is used to measurement errors okay, that is what we are using normal distribution
for and measurement errors or things where you know, it is a symmetric distribution both
negative infinity to positive infinity, we talk about that okay, so for that you use
mu bar equal to x bar and sigma bar equal to root of s square or sigma bar square equal
to s square.
Then there is one more distribution which is not that prominent but it is called as
gamma okay and gamma distribution parameters required are beta and theta, beta bar obtained
from beta tables, stat books, statistical textbooks will tell you the beta tables, from
there you can obtain the value of beta bar okay.
So, theta however can be calculated as or theta bar can be calculated as 1 over x bar
okay, theta bar can is similar to that of lambda bar but beta values you obtain, beta
bar you obtain from the textbooks okay.
In statistical textbook typically table 8, table A8 is typically what actually tells
you the gamma distribution okay, so this is a family of distributions okay, even you can
think about Erlang, Weibull, they are all kind of part of this kind of a distribution
in a way okay, alright.
So, one other thing that will lot of people asked was, how do you do the calculate for
Weibull distribution?
So, lot of the Weibull distribution is used for failure, so let me Weibull distribution
with V equal to 0 okay, if that is the case parameters required are alpha and beta okay,
so the Weibull distribution with V equal to 0 is parameter required is alpha and beta,
so first thing you do is use beta 0 bar is equal to x bar divided by S okay, so first
you calculate beta 0, then beta j bar is calculated by beta j minus 1 bar minus F of beta j minus
1 bar divided by F dash, the differential F dash of beta j minus 1 bar okay, so what
you do is beta j minus 1 minus this ratio, this particular ratio you calculate right,
then iterate until convergence, so you keep on iterating until you get 2 consecutive values
of beta j converging to a particular value beta j minus 1.
Then your alpha bar is calculated as 1 over N multiplied by sigma i equal to 1 to N, x
i the power of beta, power of 1 over beta, so the from beta 0, you can keep on doing
this, you can do beta 0 calculate that then from there you calculate beta j and you keep
on iterating until you get the convergence of the value of beta, once you get the value
of beta, then you calculate alpha bar using that particular value of beta that you obtained
okay.
So, this is used for failure okay, distributions, time to failure and other things but this
is not very common but please study from stats textbook, I have already mentioned the name
of the textbook okay, this you have to do it by yourself.
Then the last point that people have asked these because I earlier told about goodness
of fit test and people asked question about Kolmogorov-Smirnov test okay, it seems that
people have no issues understanding the chi square goodness of fit test but lot of people
had issues with the called a particular test called Kolmogorov-Smirnov, it is also known
as KS test identified by some Russians okay.
The biggest difference is okay versus chi square goodness of fit test okay, so this
test is a non-parametric test and this is a parametric test, this the normality assumption,
it requires a normality assumption which means the data do follow some normal distribution,
here is no normality assumption, you do not require any normality assumption in this particular
case okay.
So, what Kolmogorov-Smirnov test ideally do because people were having this issue with
the distance, so typically what it does is, it has an x like this okay sorry, it is an
x like this okay and then here you have f of x, f of x is the cumulative, so you have
0, 5, 10, 15, 20 like this, the values will go and you have 0.25, 0.5, 0.75, 1.0 like
this okay.
And your probabilities is cumulative will actually might look like this okay, welcome
to 1 okay, it will not go above 1, it will just come to 1 right.
The actual, this is the ideal and the actual one that you will see might do something like
this, something like this, so this is the observed from data.
What the KS test is actually doing is or this is the ideal or expected, the KS test it is
doing is, it is calculating this distance, it is this is the distance that we talk about.
So if the curve is far away okay, if the observed is too far away from ideal CDF, you cannot
assume that distribution okay, that is the fundamental idea.
So this K okay, whatever the distance or not K, D actually, this is the D that we talk
about, the D values are tabulated or available.
So if this particular D value for a particular case is less than a particular term, you can
say that okay fine, this the CDF, this graph is, so if you have another graph in this regard
and you get another set of data and this actually shows something like this, which
is close to this, then you can say that this actually, this green line fits more close
to the ideal distribution than the blue line because this distance is a much smaller okay.
So this is the fundamental idea behind the KS test, which is a non-parametric test because
you do not require the normality assumption to be satisfied as part of this.
So considering that, today now we come to the end of our presentation and also towards
the end of our course.
But one of the things that I wanted to tell everybody about this is, this is not the end
of this vast topic called simulation.
Simulation is never taught in 20 hours, it is pretty much taught over 4 to 5 semesters,
couple of years you need to work on this to get expertise in this.
And the reason why lot of the places, the simulation courses are not offered is purely
because of the extensive cost of the software and other aspects that are available for it.
But I think as far as you guys are concerned, you have been exposed to a critical topic,
which is very useful for lot of the students and as well as practitioners, it is a good
skill to have because you can actually model and solve complicated problems out of this.
So I hope that you guys understand this and you guys actually would use it in your life
to some extent.
Maybe in the coming time period in NPTEL, we would probably coming up with an advanced
course of this, where you would be having more advanced topics and advanced concepts
of simulation being covered in that.
So till that time, I hope that you guys will all have a good time, study well and do well
in your exam and try to ensure that you get all get that good certificate, so that you
can show to people that look I have acquired this skill.
Thank you very much and have a happy learning.
Thank you.
