Computationally optimized versions for mean(), std(), and var()

版本 1.0.0.0 (149.2 KB) 作者: Jorrit Montijn
Halved computation time for std() and var(), as well as a slight improvement for mean()
92.0 次下载
更新时间 2016/11/29

查看许可证

The Mathworks-supplied functions for mean(), var() and std() calculation (especially the latter two) are severely suboptimal in many cases where the calculation is performed on a matrix without NaN values. While the Mathworks-supplied versions are versatile, this makes them slow. I therefore made condensed versions that accept only two inputs: an ND input matrix (first argument) and an integer specifying which dimension to calculate the metric over (second argument).

The resulting speed-up is around 50% of original computation time for xvar() and xstd(), and 95% for xmean(), but mileage may vary. The results of xvar(), xmean() and xstd() are the same as var(), mean(), and std() up to machine precision.
By Dr. Jorrit S. Montijn, 29-11-16 (dd-mm-yy; Universite de Geneve)
=======================
The included .pdfs show the performance of the original versions versus the updated versions, according to the Matlab Profiler on my personal machine.
Disclaimer: I've tested the performance increases only on my personal PC, so you may experience better or worse improvements depending on your setup.

引用格式

Jorrit Montijn (2024). Computationally optimized versions for mean(), std(), and var() (https://www.mathworks.com/matlabcentral/fileexchange/60449-computationally-optimized-versions-for-mean-std-and-var), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2015b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Problem-Based Optimization Setup 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Edited explanatory text