sandbox-maxima-example-4

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 ”erlang

|

E_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);

.2387

Let’s evaluate T_w, the expected waiting time, for given

parameters

.

erlang|T_w (0.2 ` call/s, 240 ` s/call, 55);

8.184

⁢

s

call

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);

.8459

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);

1.6667

×

10

-

5

⁢

T

⁢

_

⁢

s

5

(

1

-

0.05

⁢

T

⁢

_

⁢

s

)

⁢

(

6.6667

×

10

-

5

⁢

T

⁢

_

⁢

s

4

+

(

1

-

0.05

⁢

T

⁢

_

⁢

s

)

⁢

(

.001333

⁢

T

⁢

_

⁢

s

3

+

0.02

⁢

T

⁢

_

⁢

s

2

+

0.2

⁢

T

⁢

_

⁢

s

+

1

)

)

⁢

s

call

Notice that T_w is undefined for (# agents)/(call intensity)

≥

1

.
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);

1

-

.2387

⁢

e

-

.02917

⁢

t

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);

λ

⁢

(

[

t

]

,

W

⁢

(

0.2

⁢

call

s

,

240

⁢

s

call

,

55

,

t

⁢

s

call

)

)

bar (15);

.8459

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];

λ

⁢

(

[

t

]

,

1

-

.2387

⁢

e

-

.02917

⁢

t

)

baz [0.2, 240, 55] (15);

.8459

That’s it for now.

build_info();

𝑏𝑢𝑖𝑙𝑑

⁢

_

⁢

𝑖𝑛𝑓𝑜

⁢

(

5.32.1

,

2014-01-02 09:53:22

,

i686-pc-linux-gnu

,

CLISP

,

2.49 (2010-07-07) (built 3539704948) (memory 3597674023)

)

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

Generated on Fri Feb 9 20:39:56 2018 by

LaTeXML