## Which MATLAB toolboxes should be merged?

A very welcome change in MATLAB 2010b is the merging of the splines and curve-fitting toolboxes to form one super-toolbox that does both splines AND curve-fitting in a product that’s simply called The Curve Fitting Toolbox. The separate curve-fitting and splines toolboxes were always a bugbear for me and many of my equivalents in other UK universities so now we have one less thing to moan about. Thanks to the HUGE number of MATLAB toolboxes, however, we’ll still have plenty of things to moan about at our quarterly academic maths and stats meetings.

I took a trawl through some of Mathworks standard toolboxes to see what other toolboxes I thought should be merged together or done away with completely. Here are a couple of pleas to The Mathworks that would make MY life (and the lives of the community I support) a whole lot easier.

### The Parallel Toolbox for MATLAB

My laptop has a dual core processor so, unless I am lucky enough to be using functions that are implicitly parallel, MATLAB will only make use of half of my available processing power. It gets worse when I get into work since it will only use a quarter of the power of my quad-core desktop and as for those lucky fellows who have just bought themselves dual hex-core MONSTERS (12 cores total)….well, MATLAB won’t exactly be using them to their full capacity will it? Less than 10% in fact, unless they shell out extra for the parallel computing toolbox (PCT).

The vast majority of computers sold today have more than one processing core and yet the vast majority of MATLAB installations out there only use one of them (unless you use these functions). MATLAB’s competitors such as Mathematica, Maple and Labview all have explicit multi-core support built in as standard. Maybe it’s time that MATLAB did that too!

**What I’d like Mathworks to do:**Merge the Parallel Computing Toolbox with core MATLAB.

### Optimisation and Global Optimisation

You’ve got a function and you want to know when it gets as big or as small as it can be so you turn to optimisation routines. MATLAB has some basic optimisation functions built into its core (fminsearch for example) but many people find that they need the extra power and versatility offered by the functions in either the optimisation toolbox or the global optimisation toolbox.

People who have never used optimisation routines before sometimes ask me what the difference between these toolboxes is. When I was first faced with this question I discussed the different classes of algorithms involved and used phrases like ‘genetic algorithms’, ‘multistart’, ‘simulated annealing’, ‘global and local minima’ and so on. These days I start off somewhat more simply:

**Me: **“The optimisation toolbox finds **A** minimum near to your starting guess. It may or may not be **THE** minimum of your function. The global optimisation toolbox, on the other hand, attempts to find **THE** minimum.”

**User:** “Well, I want **THE** minimum obviously. So, I guess I’ll take the global optimisation toolbox please.”

**Me: THE** minimum costs more money than just **A** minimum. Twice as much in fact, since you need to buy the standard optimisation toolbox **AND** the global optimisation toolbox if you want **THE** minimum.

**User:** *<Deep in thought while they consider how far their grant is going to stretch>*

**Me:** The standard optimisation toolbox won’t cost you anything here since we have a set of licenses for it on our network license server.

**User:** OK OK. I’ll make do with that. I suppose I could just make LOTS of starting guesses and run the standard optimisation toolbox routines in parallel on my 12-core monster? Then I can take the best result and there will be a better chance that it will be THE minimum, right?

**Me:** That’ll need the Parallel computing toolbox…which costs extra!

**What I’d like Mathworks to do:** Merge the standard and global optimisation toolboxes.

So, that’s a couple of things that I would like. Do you agree with them? Are there other toolbox merges you’d like to see? Comments welcome.

I use both Mathematica and Matlab for my research and I’ve found Mathematica’s user experience to be far better. The help files are better, function usage is more consistent, and, as you noted, it’s a whole package. You don’t feel like they’re nickel and diming you for features that should be standard.

I agree with Eli, the help is SOO much better. Though Matlab’s numerics is many times faster than Mathematica’s. And another issue with Mathematica is for not having nice functions for filtering (low-pass , high-pass, butterworth…. et cetera)… Though you could program your own using ListCorrelate, but you have to come up with the kernel yourself…

Sander, this is a good point about filters, but the reality is that those filters are in Matlab because someone programmed them. A lot of that kind of stuff isn’t built in. The code is there because “everybody uses Matlab” and everybody uses Matlab because the code is there. This sort of sunk cost would be easy to break.

There is a Hodrick-Prescott filter for Mathematica package for free on Wolfram’s library, and all it would take is for someone to code up the rest. I know that someone has done seasonal adjustment already, and the package will be released soon.

At some level the Demonstrations project has diverted attention away from writing packages for others to use, as occurs for Matlab, Gauss or Stata. (In fact, a lot of the useful code for Stata in economics/econometrics at least, comes from a single person.)

@LB who’s that single person?

I second the call for a wake up on the multicore front! I remember when they introduced JIT compling in version 6(?) that made matlab much quicker. Seems about time that mathworks not only worked to make code take up the full CPU benefits, but also looked to add GPU capabilities too. Of course if you want to span more than ONE physical PC, then paying a bit more would be fine.

Cheers

PEter

Hello,

a few releases ago the multi-core and multi-thread capabilities existed in core Matlab. I agree with reshifting it into Matlab.

However also Simulink has parallel capabilities now, so this is in favor of having a separate toolbox for it.

-Han

@Sander Huisman

“Though Matlab’s numerics is many times faster than Mathematica’s”

Do you have specific examples, hopefully short ones, to illustrate this? I’d like to try that, since I use both Mathematica and Matlab.

I have 2 examples, in numerics, where Mathematica was actually faster than Matlab.

I did a matrix rank test some time ago, and I also did finite difference scheme for pde and a direct solver using sparse matrix. In both cases, Mathematica was faster (2 times faster in the later case).

So any test case I can use to help me compare the speed of these 2 applications I would be interested in. I hear people say that Matlab is faster in numerics that Mathematica, but never seen any one actually show an example.

Here is the rank test (this was 3 years ago)

http://12000.org/my_notes/rankTest/test.htm

A recent one (Matlab 2010a and Mathematica 7.0), For direct solver, I solved in sparse array large systems.

I compared the speed of the Mathematica LinearSolver with the Matlab “\” solver for sparse A, for different size Matrices, and Mathematica is 2 times as fast:

(both systems use the UMFPACK multifrontal direct solver methods when A is sparse)

note: n below means A is of size n^ by n^2 and not n by n, but these are

mostly zero elements, hence sparse matrix is used) (this is a problem to

solve Poisson pde on 2D on unit square)

In Matlab, I used cputime() to time the direct solver cpu time used, and in Mathematics I used Timing[], all timing on my PC. These are CPU timing, not clock wall times. PC is new intel machine.

————–CPU speed ————-

n=31, CPU(Matlab)=0.015 CPU(Mathematica)=0.016

n=63, CPU(Matlab)=0.13 CPU(Mathematica)=0.015

n=127, CPU(Matlab)=0.25 CPU(Mathematica)=0.063

n=255, CPU(Matlab)=1.54 CPU(Mathematica)=0.36

n=511, CPU(Matlab)=5.54 CPU(Mathematica)=2

n=1023, CPU(Matlab)=27.1 CPU(Mathematica)=14.62

———————–

I’ll be happy to provide link for the code for the above.

I am no expert in performance of numerics at all, I am only a student. Also the above might not mean much as they are selected cases.

So, any small code example you can show which shows Matlab is faster in numerics? small code examples that one can code in Mathematica to compare is best.

Thanks

–Nasser

Dear Mike, sorry I never came back to this thread to respond to your question. Christopher Baum of Boston College is the person responsible for producing many of the Stata modules for time-series econometrics http://ideas.repec.org/e/pba1.html#software

http://fmwww.bc.edu/ec/Baum.php

http://www.stata-press.com/books/imeus.html

It turns out that he was also able to turn each of these software components into a publication in a journal as well (Stata Technical Bulletin), which looks great on RePEc. (e.g. http://stata-press.com/journals/stbcontents/stb60.pdf, http://ideas.repec.org/a/tsj/stbull/y2001v10i60sts18.html)