{"id":2782,"date":"2010-07-29T17:25:11","date_gmt":"2010-07-29T16:25:11","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=2782"},"modified":"2010-07-29T17:25:11","modified_gmt":"2010-07-29T16:25:11","slug":"an-alternative-to-the-ranksum-function-using-the-nag-toolbox-for-matlab","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=2782","title":{"rendered":"An alternative to the ranksum function using the NAG toolbox for MATLAB"},"content":{"rendered":"<p>The MATLAB function <strong><a href=\"http:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/stats\/ranksum.html\">ranksum<\/a> <\/strong>is part of MATLAB&#8217;s <a href=\"http:\/\/www.mathworks.com\/products\/statistics\/\"> Statistics Toolbox<\/a>. Like many organizations who use network licensing for MATLAB and its toolboxes, my employer, The University of Manchester, sometimes runs out of licenses for this toolbox  which leads to following error message when you attempt to evaluate <strong>ranksum<\/strong>.<\/p>\n<pre>??? License checkout failed.\r\nLicense Manager Error -4\r\nMaximum number of users for Statistics_Toolbox reached.\r\nTry again later.\r\nTo see a list of current users use the lmstat utility or contact your License Administrator.<\/pre>\n<p>An alternative to the Statistics Toolbox is the <a href=\"http:\/\/www.nag.co.uk\/numeric\/MB\/start.asp\">NAG Toolbox for MATLAB<\/a> for which we have an unlimited number of licenses.  Here&#8217;s how to replace <strong>ranksum<\/strong> with the NAG routine <strong>g08ah<\/strong>.<\/p>\n<p><strong>Original MATLAB \/ Statistics Toolbox code<\/strong><\/p>\n<pre>x = [0.8147;0.9058;0.1270;0.9134;0.6324;0.0975;0.2785;0.5469;0.9575;0.9649];\r\ny=  [0.4076;1.220;1.207;0.735;1.0502;0.3918;0.671;1.165;1.0422;1.2094;0.9057;0.285;1.099;1.18;0.928];\r\np = ranksum(x,y)<\/pre>\n<p>The result is p = 0.0375<\/p>\n<p><strong>Code using the NAG Toolbox for MATLAB<\/strong><\/p>\n<pre>x = [0.8147;0.9058;0.1270;0.9134;0.6324;0.0975;0.2785;0.5469;0.9575;0.9649];\r\ny =  [0.4076;1.220;1.207;0.735;1.0502;0.3918;0.671;1.165;1.0422;1.2094;0.9057;0.285;1.099;1.18;0.928];\r\ntail = 'T';\r\n[u, unor, p, ties, ranks, ifail] = g08ah(x, y, tail);<\/pre>\n<p>The value for p is the same as that calculated by <strong>ranksum<\/strong>: p = 0.0375<\/p>\n<p>NAG&#8217;s <a href=\"www.nag.co.uk\/numeric\/MB\/manual_22_1\/pdf\/G08\/g08ah.pdf\"><strong>g08ah<\/strong><\/a> routine returns a lot more than just the  value p but, for this particular example, we can just ignore it all.   In fact, if you have MATLAB 2009b or above then you could call <strong>g08ah<\/strong> like this<\/p>\n<pre>tail = 'T';\r\n[~, ~, p, ~, ~, ~] = g08ah(x, y, tail);<\/pre>\n<p>Which explicitly indicates that you are not going to use any of the outputs other than p.<\/p>\n<p>People at Manchester are using the NAG toolbox for MATLAB more and more; not only because we have a full site license for it but because it can sometimes be <strong>very fast<\/strong>.\u00a0 Here&#8217;s some more articles on the NAG toolbox you may find useful.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=1552\">A faster version of MATLAB\u2019s interp1<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=2351\">An alternative to binopdf using the NAG toolbox for MATLAB<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=1590\">Mark 22 of the NAG toolbox for MATLAB released<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The MATLAB function ranksum is part of MATLAB&#8217;s Statistics Toolbox. Like many organizations who use network licensing for MATLAB and its toolboxes, my employer, The University of Manchester, sometimes runs out of licenses for this toolbox which leads to following error message when you attempt to evaluate ranksum. ??? License checkout failed. License Manager Error [&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":[11,28,41],"tags":[],"class_list":["post-2782","post","type-post","status-publish","format-standard","hentry","category-matlab","category-nag-library","category-parallel-programming"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-IS","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2782","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=2782"}],"version-history":[{"count":2,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2782\/revisions"}],"predecessor-version":[{"id":2784,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2782\/revisions\/2784"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}