{"id":2383,"date":"2010-03-05T18:25:19","date_gmt":"2010-03-05T17:25:19","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=2383"},"modified":"2010-03-05T18:25:27","modified_gmt":"2010-03-05T17:25:27","slug":"more-matlab-statistics-toolbox-licensing-woes-and-how-tol-solve-them","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=2383","title":{"rendered":"More MATLAB statistics toolbox licensing woes (and how to solve them)"},"content":{"rendered":"<p>A little while ago I was having a nice tea break when all hell broke loose.\u00a0 Complaint after complaint started rolling in about lack of network licenses for the <a href=\"http:\/\/www.mathworks.co.uk\/products\/statistics\/\">MATLAB statistics toolbox<\/a> and everyone was wondering what I intended to do about it.\u00a0 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.\u00a0 Slowly but surely, he was eating up every statistics toolbox license in the university.<\/p>\n<p>I contacted him, explained the problem and he terminated all of his jobs.\u00a0 Life returned to normal for the rest of the university but now he couldn&#8217;t work.\u00a0 What to do?<\/p>\n<p>One option was to compile his code using the MATLAB compiler and send the resulting binaries to the cluster but I took another route.\u00a0 I had a look through his code and discovered that he was only ever calling one function from the Statistics toolbox and that was<\/p>\n<pre>\r\nrandom('unif',0,1)\r\n<\/pre>\n<p>All this does is give a uniform random number between 0 and 1.  However, if you code it like this<\/p>\n<pre>\r\nrand()\r\n<\/pre>\n<p>then you won&#8217;t use a license from the statistics toolbox since rand() is part of basic MATLAB.  Of course most people don&#8217;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<\/p>\n<pre>\r\nr = a + (b-a).*rand();     %Doesn't use a license for the statistics toolbox\r\nr = random('unif',a,b);    %Does use a license for the statistics toolbox\r\n<\/pre>\n<p>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().<\/p>\n<pre>\r\nrandom('norm',mu,sigma);  %does use a stats license\r\nr = randn()* sigma + mu;  %doesn't use a stats license\r\n<\/pre>\n<p>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 ;)  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A little while ago I was having a nice tea break when all hell broke loose.\u00a0 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.\u00a0 A quick look at our license server indicated that someone had started [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,11,7],"tags":[],"class_list":["post-2383","post","type-post","status-publish","format-standard","hentry","category-math-software","category-matlab","category-programming"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-Cr","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2383"}],"version-history":[{"count":7,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2383\/revisions"}],"predecessor-version":[{"id":2390,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2383\/revisions\/2390"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}