Efficiently Averaging Large Sets: Store now, Average later vs. Update now
1 回表示 (過去 30 日間)
古いコメントを表示
I am wondering if it is more efficient to store large amounts of data and average later or to update the average as data is generated and reduce the storage requirement.
I am looping over the number of samples, S. All vectors and matrices are of unique dimension and are organized in cells. The result of each loop iteration is N new vectors and N new matrices.
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278378/image.png)
Sooner or later, I need to average S column vectors N times, and S Matrices N times.
I see two fundamental approaches to this problem:
1) Create N vectors and N matrices and update them every loop iteration to reflect the average:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278379/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278380/image.png)
So there would be
storage requirements and
of these calculations.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278381/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278382/image.png)
2) Store
vectors and
matrices, and then call the MatLab function mean()
times to recover the averages.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278383/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278384/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278385/image.png)
So there would be
storage requirements and the mean() function would be called
times.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278386/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278387/image.png)
My gut tells me
calculations is a losing proposition, but I wonder if someone with more expertise than me could comment? Thank you!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278388/image.png)
2 件のコメント
Aghamarsh Varanasi
2020 年 3 月 24 日
Choosing one of the approach that you have mentioned should totally depend on your design and other constraints. For example, If you wanted to develop the algorithm for a system with memory limitations, then you could use the first approach. If you wanted less computation, you can use the second approach.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!