Coursework FAQs
1. You say "write a simulator". What language should I use?
It's up to you! You could use Java, C++, Python, R, Mathematica,
Matlab, or whatever you like. You could write a program in Visual
Basic which outputs the results in plain text, then load them into
Excel to produce graphical output.
You should in the first instance ask each other for help about
whatever programming language you use. I can also help with R,
Mathematica, Java, Excel, and Python.
2. How do I generate an exponential random variable?
Most programming languages have a primitive which can generate a
random number in the range [0,1]. Let U be such a number.
Now let X= −log(U)/λ. Then
X is an Exponential random variable with rate
λ.
Additionally, some programming languages have primitives for
generating exponential random variables. In R, the code is
rexp(1,rate=r)
.
3. What's a confidence interval?
Look at your notes from Section 7.4.2 of the first half of the course.
If you do
n experiments to measure a quantity
x, and your
n measurements are
X1,
X2, ...,
Xn, then the procedure is as
follows:
-
calculate the mean, μ=(X1 +
X2 + ... +
Xn)/n.
-
calculate the variance,
(Σ(Xi-μ)2)/(n-1)
-
calculate the standard deviation, σ=(variance)1/2
-
the 95% confidence interval for x is then
[μ-1.96σ μ+1.96σ].
4. How many measurements should I take of the blocking
probability?
The more you take, the smaller σ will be, and the tighter your
confidence interval will be.
For the purposes of this coursework, I don't mind how many you take,
as long as you demonstrate that you know what you're doing.
5. How long should I run the simulator for, to obtain a good
estimate for the blocking probability?
For the purposes of this coursework, I don't mind how long you run it
for, as long as you demonstrate that you know what you're doing. You
needn't spend more than 15 minutes of computing time running the
simulation.
6. Can you remind me what a Poisson process is?
Let's say that buses arrive as a Poisson process of rate λ. That
means that the interval between successive buses is an Exponential
random variable, with rate λ, i.e. with mean 1/λ.
7. In the Erlang model, what's the relationship between the
arrival process and the holding times? Are they both
exponentials?
Let's suppose that the arrivals are a Poisson process of rate λ,
and
that call holding times are Exponential and have mean 1/μ, i.e. have
rate
μ. That means that the time between two successive arrivals is an
Exponential random variable of rate λ, and that the time between
a call
arriving and departing is Exponential of rate μ. Don't get the two
mixed
up. Arrivals are a Poisson
process. It doesn't mean anything to say
"arrivals are Exponential" (although it is perfectly proper to say
"inter-arrival times are Exponential").
Note also that the number of arrivals that occur in an interval of
length T has a Poisson distribution with parameter
λT. There are two separate concepts here: a Poisson
arrival process, and a Poisson distribution. If you're
as clever as Poisson, I'm sure you'll get several different things named after
you too.
8. What's the function to calculate the equilibrium distribution of a Markov
process?
-
In Mathematica, if Q is the Q-matrix, then
NullSpace[Transpose[Q]]
returns a vector x such
that x.Q=0. The equilibrium distribution is a
normalized version,
π=x/(Plus @@ x)
.
-
In Matlab, if Q is the Q-matrix, then
null(Q')
returns x as above, and
π=x/sum(x)
.
-
In R, use something like
library(MASS)
qmat <- matrix(0, nrow=3,ncol=3)
qmat[1,] <- c(-5,2,3)
qmat[2,] <- c(2,-3,1)
qmat[3,] <- c(1,1,-2)
x <- Null(qmat)
x/sum(x)
-
In Excel, I've provided a worksheet
[
eqmcalc.xls
]
which shows how to calculate an equilibrium distribution.
9. What do you mean by "blocking probability", and how should I
measure it?
You have to work that out yourself.
10. How will my program be marked? What if there's a bug in my code?
What if my code is inefficient?
You should explain the purpose and reasoning behind your code.
-
If there's a bug in your code, but your explanation of what the code
is meant to do is complete and correct, then you will gain
credit for your program.
-
If you suspect there's a bug in your code, and you
explain clearly what observations you've made that lead to you
conclude that there's a bug, and your explanation is logical,
then you will gain nearly full credit for
your program.
-
If your program works correctly and produces valid
answers, but you fail to give any explanation of how it works, then
(a) I will look carefully for hints of plagiarism, and (b) you will
gain nearly full credit for your program.
-
If your program has a bug, and you give no explanation of how it
works, you will get zero credit.
You do not need to spend too much time making your code efficient. I
don't expect the program to run for more than 15 minutes on a modern
computer.