打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Matlab vs. R performance benchmarking
University of Cambridge >  Department of Engineering >  Information Engineering  >  Computational and Biological Learning Lab  > David Knowles

Matlab vs. R performance benchmarking

A somewhat outdated comparison of Matlab and R (and a variety of other packages) can be found here. Unfortunately the R code istoo outdated to run with the current (2.8.1) version but you can find a more up to date version here.

I've added five statistical functions tests to the benchmark. The Matlab code is here and the R code is here.

Set up

Each test was run twenty times on a Intel Core 2 1.86Ghz machine with4Gb RAM running Windows Vista Business. I increased the number ofrepeats from three to twenty since most of the calculationsrely on random numbers which will be different in each program. A muchbetter solution for the matrix calculations would be to use the samerandomly generated matrices ineach program, maybe I'll do that sometime!
I was using Matlab 2008b and R 2.8.0.

What conclusions can we draw?

Matlab is still on an order of twice as fast as R for Matrixoperations. Also, Matlab can sometimes workout how to vectorise loops -which is why the loop test here concludes that Matlab is 400 timesfaster than R! I should really write a new loop test that Matlab isn'table to vectorise! For statistical functions it is less clear cut.

Naturally, speed is not necessarily a key consideration. We'd allbe using C if it was after all. Personally, I prefer R's flexibleplotting, rich data structures, package management and free-ness. ButI'll admit it's far from perfect. But I'll admit it's far from perfect,and Matlab does have a lot of great features (like the profiler) andclean syntax.

I. Matrix calculation R (sec) Matlab (sec) R/Matlab
Creation, transp., deformation of a 1500x1500 matrix 0.371 0.175 2.114
800x800 normal distributed random matrix 1000 0.179 0.135 1.323
Sorting of 2,000,000 random values 0.421 0.354 1.189
700x700 cross-product matrix 0.543 0.069 7.891
Linear regression over a 600x600 matrix 0.416 0.063 6.654
II. Matrix functions


FFT over 800,000 random values 0.443 0.129 3.441
Eigenvalues of a 320x320 random matrix 0.378 0.452 0.835
Determinant of a 650x650 random matrix 0.157 0.065 2.399
Cholesky decomposition of a 900x900 matrix 0.256 0.087 2.954
Inverse of a 400x400 random matrix 0.105 0.047 2.223
III. Programmation


750,000 Fibonacci numbers calculation (vector calc) 0.349 0.292 1.195
Creation of a 2250x2250 Hilbert matrix (matrix calc) 0.575 0.269 2.137
Grand common divisors of 70,000 pairs (recursion) 0.470 0.075 6.230
Creation of a 220x220 Toeplitz matrix (loops) 0.290 0.001 402.108
Escoufier's method on a 37x37 matrix (mixed) 0.550 0.636 0.865
IV. Statistics


Generating 107 uniform(0,1) random numbers 1.136 0.338 3.364
Create a permutation of [1..106 ] 0.078 0.257 0.304
Sample from binomal(100,.5) 105 times 0.061 0.480 0.126
Sample from N(0,1) 106 times 0.334 0.036 9.163
Evaluate N(0,1) at 106 locations 0.558 0.077 7.240
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
加速matlab运行
matlab提速技巧(自matlab帮助文件)
Fisher information
Riemann 猜想漫谈
Improving Simulation Performance in Simulink
c++
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服