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

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

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

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

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

a “business” opportunity?…

hmmmm

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