sandbox-maxima-example-4
Let’s express some well-known formulas for service waiting time, for which telephone calls are a commonly-used example. Discussion here is based on a web page [1] which states the formulas. I’ll just copy the formulas verbatim and show how Maxima can carry out some interesting operations with them.
The erlang.mac script makes use of a couple of Maxima add-ons. It puts the functions it defines in a namespace ”erlang” so I’ll write ”erlangE_c” to refer to the function E_c in the namespace erlang. Also, the script assumes that quantities (e.g., time) come with units attached.
As with other articles about worked examples, I’m including only the barest outline and omitting a lot of details. If you’re interested, we can follow up in the comments.
[1] http://www.mitan.co.uk/erlang/elgcmath.htm
fpprintprec : 4 $ batch ("./erlang.mac");
./erlang.mac |
1 Numerical examples
Let’s reproduce the examples from the web page. First let’s compute E_c for a given lambda, T_s, and m.
erlang|E_c (0.2 ` call/s, 240 ` s/call, 55);
Let’s evaluate T_w, the expected waiting time, for given parameters.
erlang|T_w (0.2 ` call/s, 240 ` s/call, 55);
Let’s compute the probability that waiting time is less than or equal to 15 seconds.
erlang|W (0.2 ` call/s, 240 ` s/call, 55, 15 ` s/call);
2 Symbolic operations
So far, so good; the numerical values agree with those stated on the web page. Let’s look at some symbolic operations. If some parameters are unknown, the functions return expressions in the unknown parameters. Given fixed values for call intensity and number of agents, how does expected waiting time vary as a function of the average call duration?
foo : erlang|T_w (0.2 ` call/s, T_s ` s/call, 4);
Notice that T_w is undefined for (# agents)/(call intensity) . As that ratio approaches 1 from below, the expected waiting time increases without bound.
plot2d (qty (foo), [T_s, 0, 4/0.2], [y, 0, 100]);
Likewise, the function P(waiting time ¡= t) is a function of t alone given other parameters.
erlang|W (0.2 ` call/s, 240 ` s/call, 55, t ` s/call);
Let’s construct a function which takes just t as an argument. The other parameters are baked in.
W (t) := ''(erlang|W (0.2 ` call/s, 240 ` s/call, 55, t ` s/call));
W(t):=1-.2387*%e^-(.02917*t);
Let’s take a look at that function W.
plot2d (W, [t, 0, 50]);
Another way to approach this is to construct a lambda expression (anonymous function).
foo (a, b, c) := buildq ([a, b, c], lambda ([t], erlang|W (a, b, c, t ` s/call)));
foo(a,b,c):=buildq([a,b,c], ?common\-lisp|?lambda([t],erlang|W(a,b,c,t ` s/call)));
bar : foo (0.2 ` call/s, 240 ` s/call, 55);
bar (15);
Finally, let’s construct a memoizing function (called an ”array function” in Maxima). We can think of this as a family of functions of t which are indexed by the parameters.
baz [%lambda, T_s, m] (t) := erlang|W (%lambda ` call/s, T_s ` s/call, m, t ` s/call);
baz[%lambda,T_s,m](t):=erlang|W(%lambda ` call/s,T_s ` s/call,m,t ` s/call);
baz [0.2, 240, 55];
baz [0.2, 240, 55] (15);
That’s it for now.
build_info();
Title | sandbox-maxima-example-4 |
---|---|
Canonical name | Sandboxmaximaexample4 |
Date of creation | 2014-03-07 15:03:21 |
Last modified on | 2014-03-07 15:03:21 |
Owner | robert_dodier (1000903) |
Last modified by | robert_dodier (1000903) |
Numerical id | 17 |
Author | robert_dodier (1000903) |
Entry type | Example |