More MATLAB statistics toolbox licensing woes (and how to solve them)

March 5th, 2010 | Categories: math software, matlab, programming | Tags:

A little while ago I was having a nice tea break when all hell broke loose.  Complaint after complaint started rolling in about lack of network licenses for the MATLAB statistics toolbox and everyone was wondering what I intended to do about it.  A quick look at our license server indicated that someone had started a large number of MATLAB jobs on a Beowulf cluster and all of them used the statistics toolbox.  Slowly but surely, he was eating up every statistics toolbox license in the university.

I contacted him, explained the problem and he terminated all of his jobs.  Life returned to normal for the rest of the university but now he couldn’t work.  What to do?

One option was to compile his code using the MATLAB compiler and send the resulting binaries to the cluster but I took another route.  I had a look through his code and discovered that he was only ever calling one function from the Statistics toolbox and that was

random('unif',0,1)

All this does is give a uniform random number between 0 and 1. However, if you code it like this

rand()

then you won’t use a license from the statistics toolbox since rand() is part of basic MATLAB. Of course most people don’t want a random number between 0 and 1; instead they will want a random number between two constants, a and b. In almost all cases the following two statements are mathematically equivalent

r = a + (b-a).*rand();     %Doesn't use a license for the statistics toolbox
r = random('unif',a,b);    %Does use a license for the statistics toolbox

The statistics toolbox function, random(), is much more general than rand() since it can give you random numbers from many different distributions but you are wasting a license token if you use it for the uniform distribution. The same goes for the normal distribution for that matter since basic MATLAB has randn().

random('norm',mu,sigma);  %does use a stats license
r = randn()* sigma + mu;  %doesn't use a stats license

The moral of the story is that when you are using MATLAB in a network licensed environment, it can sometimes pay to consider how you spell your functions ;)

  1. March 8th, 2010 at 14:46
    Reply | Quote | #1

    Another alternative might be to find the equivalent function in a different toolbox – say [to pick an example entirely at random ;-)] the NAG Toolbox for MATLAB, which is apparently fully licensed at your site. This contains a wide variety of random number generators, although it might take a little while to find the one you want amongst all those names – which perhaps only goes to reinforce your point about taking care when spelling your functions. ;-)

  2. March 8th, 2010 at 14:58
    Reply | Quote | #2

    Hi Jeremy

    We use the NAG toolbox a lot at Manchester and I wrote up a specific example a couple of weeks ago http://www.walkingrandomly.com/?p=2351

    The NAG Toolbox’s biggest problem is that not all of the functions are vectorized. Those that are, however, usually demonstrate a good speedup compared to the Mathworks’ equivalents. For example, http://www.walkingrandomly.com/?p=1552

    Cheers,
    Mike

  3. GG
    March 13th, 2010 at 12:54
    Reply | Quote | #3

    “biggest problem is that not all of the functions are vectorized”

    a “business” opportunity?…
    hmmmm

  4. March 13th, 2010 at 14:36
    Reply | Quote | #4

    @GG Not sure I follow your meaning. I just moan at NAG about it and hope they fix it.